Hardware/software Interfacing. Page 2 Interrupt handling and using internal timer Two way for processor to accept external input: Waiting for input: Processor.

Slides:



Advertisements
Similar presentations
Computer System Organization Computer-system operation – One or more CPUs, device controllers connect through common bus providing access to shared memory.
Advertisements

1 (Review of Prerequisite Material). Processes are an abstraction of the operation of computers. So, to understand operating systems, one must have a.
M. Mateen Yaqoob The University of Lahore Spring 2014.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
I/O Unit.
Computer System Overview
Cache Memory Locality of reference: It is observed that when a program refers to memory, the access to memory for data as well as code are confined to.
Chapter 1 Computer System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Computer System Overview
1 Computer System Overview OS-1 Course AA
Memory Organization.
1 CSIT431 Introduction to Operating Systems Welcome to CSIT431 Introduction to Operating Systems In this course we learn about the design and structure.
Computer System Overview
University College Cork IRELAND Hardware Concepts An understanding of computer hardware is a vital prerequisite for the study of operating systems.
Chapter 1 and 2 Computer System and Operating System Overview
Programming I/O for Embedded System. Page 2 Overview Basis: A DE2 Computer Architecture Parallel I/O 7-Segment Display Basic Manipulating 7-Segment Display.
Computer System Overview Chapter 1. Basic computer structure CPU Memory memory bus I/O bus diskNet interface.
CSCI2413 Lecture 6 Operating Systems Memory Management 2 phones off (please)
Dr. Kimberly E. Newman Hybrid Embedded wk3 Fall 2009.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.
Input/Output. Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower.
General System Architecture and I/O.  I/O devices and the CPU can execute concurrently.  Each device controller is in charge of a particular device.
Memory Hierarchy.
COMP201 Computer Systems Exceptions and Interrupts.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
Chapter 1 Computer System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Computer Systems Overview. Page 2 W. Stallings: Operating Systems: Internals and Design, ©2001 Operating System Exploits the hardware resources of one.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Computer System Overview Chapter 1. Operating System Exploits the hardware resources of one or more processors Provides a set of services to system users.
Chapter 1 Computer System Overview Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
MICROPROCESSOR INPUT/OUTPUT
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
2: Computer-System Structures
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Operating Systems and Networks AE4B33OSS Introduction.
(More) Interfacing concepts. Introduction Overview of I/O operations Programmed I/O – Standard I/O – Memory Mapped I/O Device synchronization Readings:
Ihr Logo Operating Systems Internals & Design Principles Fifth Edition William Stallings Chapter 1 Computer System Overview.
1 Memory Hierarchy The main memory occupies a central position by being able to communicate directly with the CPU and with auxiliary memory devices through.
Interrupts, Buses Chapter 6.2.5, Introduction to Interrupts Interrupts are a mechanism by which other modules (e.g. I/O) may interrupt normal.
Operating System Isfahan University of Technology Note: most of the slides used in this course are derived from those of the textbook (see slide 4)
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
MEMORY ORGANIZATION - Memory hierarchy - Main memory - Auxiliary memory - Cache memory.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Lecture 1: Review of Computer Organization
Overview von Neumann Architecture Computer component Computer function
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
بسم الله الرحمن الرحيم MEMORY AND I/O.
1 Computer Architecture. 2 Basic Elements Processor Main Memory –volatile –referred to as real memory or primary memory I/O modules –secondary memory.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Lab 2 Microprocessor MPC430F2274 MSP-430 Architecture.
Computer Systems Overview. Lecture 1/Page 2AE4B33OSS W. Stallings: Operating Systems: Internals and Design, ©2001 Operating System Exploits the hardware.
Index What is an Interface Pins of 8085 used in Interfacing Memory – Microprocessor Interface I/O – Microprocessor Interface Basic RAM Cells Stack Memory.
1 Computer System Overview Chapter 1. 2 Operating System Exploits the hardware resources of one or more processors Provides a set of services to system.
Chapter 1 Computer System Overview
Memory COMPUTER ARCHITECTURE
Module 2: Computer-System Structures
MICROPROCESSOR MEMORY ORGANIZATION
Chapter 5: Computer Systems Organization
MICROPROCESSOR MEMORY ORGANIZATION
Module 2: Computer-System Structures
Chapter 1 Computer System Overview
Module 2: Computer-System Structures
Presentation transcript:

Hardware/software Interfacing

Page 2 Interrupt handling and using internal timer Two way for processor to accept external input: Waiting for input: Processor will be halting and listening to the input port until data is transmitted while(data is not updated){ read data from address of some I/O port }

Page 3 Interrupt handling and using internal timer Interrupt: Data arrival will start an interrupt request to processor, when a interrupt is generated, processor will stop it’s current work and turn to interrupt service function (data receive), and resume work after interrupt is handled. interrupt_func() { transmit data from I/O port to processor } Main() { setup interrupt handling function }

Page 4 Interrupt Request “interrupt request" (or IRQ) is used to refer to either the act of interrupting the bus lines used to signal an interrupt, or the interrupt input lines on a Programmable Interrupt Controller Generated when an I/O event occurs, handled by interrupt controller Interrupts from different sources are differentiated by IRQ line number

Page 5 IRQ setting in DE2 Computer DeviceIRQ JTAG_UART0 Internal Timer1 Push Button2

Page 6 Interrupt handler function NIOS Processer keeps a special address in memory ad the entry point for interrupt handler function Exception Vector: stores the address of interrupt handler function, when an IRQ is received by processor, it will save the instruction context and jump to interrupt handler function.

Page 7 How to use interrupt handler Enable corresponding IRQ line to processor in SOPC builder Set I/O devices to enable external interrupt generation Enable the interruptmask register of Parallel I/O The ITO bit in internal timer control register Write interrupt handler function Register interrupt handler function

Page 8 Code sample for interrupt handler setup Include files: #include "system.h" #include "alt_types.h" #include "sys/alt_irq.h" #include "sys/alt_sys_init.h"

Page 9 Pseudo-Code sample for interrupt handler setup void interrupt_handler() { … } main() { enable system irq register handler of irqX as interrupt_handler }

Page 10 Internal Timer NIOS Internal Timer Works as a stop watch, period register and control signals are set by user by programming, once started, counter will count down from the value in period register to 0 and generate an interrupt when time is over.

Page 11 Top-level timer diagram

Page 12 Timer configuration

Page 13 Timer configuration Configured in SOPC Builder

Page 14 Register File for Internal Timer

Page 15 Register File for Internal Timer

Page 16 Register File for Internal Timer

Page 17 Register File for Internal Timer

Page 18 How to use internal timer in programming Internal timer will loopingly count down from value in period register to 0, when counter reaches 0, an interrupt on IRQ 1 will be generated, user need to write IRS function for IRQ 1 to capture timer events In DE2 Computer, the period of timer is 1 ms, means the interrupt will occur 1000 per second

Page 19 How to use internal timer in programming #include "system.h" #include "alt_types.h" #include "altera_avalon_timer_regs.h" #include "altera_avalon_timer.h" #include "sys/alt_irq.h" #include "sys/alt_sys_init.h"

Page 20 Macros for timer register file access IORD_ALTERA_AVALON_TIMER_STATUS(base) IOWR_ALTERA_AVALON_TIMER_STATUS(base, data) // Read/write to 16 bits status register IORD_ALTERA_AVALON_TIMER_CONTROL(base) IOWR_ALTERA_AVALON_TIMER_CONTROL(base, data) // Read/write to 16 bits control register IORD_ALTERA_AVALON_TIMER_PERIODL(base) IOWR_ALTERA_AVALON_TIMER_PERIODL(base, data) // Read/write to lower 16 bits of period register IORD_ALTERA_AVALON_TIMER_PERIODH(base) IOWR_ALTERA_AVALON_TIMER_PERIODH(base, data) // Read/write to higher 16 bits of period register

Page 21 How to use internal timer in programming Write user IRS function static void Timer_Interrupts(void *context,alt_u32 id) { if(Timer_counter >= 1000) /* 1S */ { Timer_counter = 0; //global variable to store reached counter event } else { Timer_counter++; } IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_BASE, 0x00);//clear status register }

Page 22 How to use internal timer in programming Register IRS alt_irq_register(TIMER_IRQ,NULL,Timer_Interrupts); //Register IRS IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_BA SE, 0x07); //Start timer

Page 23 How to capture Timer event in user program Keep a global variable for storing information from timer events, in main function, check the global variable to update timer events static int timer_event; interrupt_handler() { …. //set timer_event } main() { register IRS function while(timer_event updated) { … user actions } }

Page 24 Summary DE2 Computer A basic hardware configuration in Quartus for embedded system software design Parallel I/O Basic, register file structure and programming 7-Segment LED Driven by parallel I/O, programming and display Interrupt handling Basic concepts, and how to use in programming Internal Timer Basic, register file structure and programming

Page 25 HW 1 Answer keys 1: Draw and describe the memory hierarchy of an embedded system Figure 5-1

Page 26 2 Which memory component in a memory hierarchy is typically located on board A: Level-2 cache B: Main memory C: Secondary memory D: All of the above E: None of the above D

Page 27 3 [a] What is ROM [b] Name and describe three type of ROM ROM=Read Only Memory, a type of non-volatile memory that can be used to store data on an embedded system permanently MASK ROM OTPROM EPROM...

Page 28 [a] What is RAM [b] Name and describe 3 types of RAM Random Access Memory=location within it can be accessed directly and randomly SRAM SDRAM DRDRAM …

Page 29 [a] Draw examples of ROM, SRAM and DRAM memory cells [b] Describe the main differences between these memory cells figure 5-6, figure 5-9, and figure 5-11 a ROM: contains bipolar or MOSFET transistor SRAM: 6 transistors, lost data when power off DRAM: one transistor and one capacitor, need refreshed to keep data

Page 30 SRAM is usually used in external cache, because SRAM is slower than DRAM FALSE

Page 31 What type of memory is typically used as main memory DRAM

Page 32 [a] What is the difference between level1,2,3 cache [b] How do they all work together in a system speed: fast, medium, slow cost: high, medium, low Processor first check level 1 cache, if miss, check level 2 cache … if all caches miss, goes to main memory

Page 33 [a] What is the most common schemes used to store and retrieve data in cache [b] what is the difference between cache hit and cache miss Direct mapped, set associative, full associative Cache hit: the data is in the cache miss: data is not in cache

Page 34 Name and describe at least 4 cache swapping schemes Optimal, LRU, FIFO, NRU

Page 35 Auxiliary memory is typically classified according to how data is accessed True

Page 36 What is the differences between physical memory and logical memory Physical memory is the real memory on board Logical memory is a virtual memory space, implemented by OS, to provide a convenient way for software development

Page (2) How can memory impact the performance of a system Difference in band width and frequency can slow down data access period Limited memory will frequently cause page fault, exchanging pages out from and into memory will be a large overhead for system.