1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 4: Bit of ssembly, Memory-mapped I/O, APB January 21, 2014.

Slides:



Advertisements
Similar presentations
Homework Reading Machine Projects Labs
Advertisements

Computer Architecture
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
Engineering 4862 Microprocessors Lecture 23 Cheng Li EN-4012
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 5: Memory and Peripheral Busses September 21, 2010.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 6: AHB-Lite, Interrupts (1) September 18, 2014 Slides developed.
Basic Input/Output Operations
68000 Interface Timing Diagrams Outline –68000 Read Cycle –68000 Write Cycle Goal –Understand bus cycles –Learn how to attach memory, peripherals.
Microprocessor or Microcontroller Not just a case of “you say tomarto and I say tomayto” M. Smith, ECE University of Calgary, Canada.
1 COMP541 Interrupts, DMA, Serial I/O Montek Singh April 24, 2007.
Interfacing. This Week In DIG II  Basic communications terminology  Communications protocols  Microprocessor interfacing: I/O addressing  Port and.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 4: Memory-Mapped I/O, Bus Architectures January 20, 2015.
9/20/6Lecture 3 - Instruction Set - Al Hardware interface (part 2)
Practical Session No. 10 Input &Output (I/O). I/O Devices Input/output (I/O) devices provide the means to interact with the “outside world”. An I/O device.
Interface circuits I/O interface consists of the circuitry required to connect an I/O device to a computer bus. Side of the interface which connects to.
Lecture 12 Today’s topics –CPU basics Registers ALU Control Unit –The bus –Clocks –Input/output subsystem 1.
COMP201 Computer Systems Exceptions and Interrupts.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 5: Memory and Peripheral Busses September 20, 2011.
NS Training Hardware.
MICROPROCESSOR INPUT/OUTPUT
BASIC INPUT AND OUTPUT INTERFACING.  8085A communicate with outside world using the I/O devices.  Since memory and I/O devices share the system bus,
Spring EE 437 Lillevik 437s06-l8 University of Portland School of Engineering Advanced Computer Architecture Lecture 8 Project 3: memory agent Programmed.
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
I/O Example: Disk Drives To access data: — seek: position head over the proper track (8 to 20 ms. avg.) — rotational latency: wait for desired sector (.5.
Computer Architecture Lecture10: Input/output devices Piotr Bilski.
On Chip Bus National Taiwan University
© 2000 Morgan Kaufman Overheads for Computers as Components System components  Timing diagrams.  Memory.  Busses and interconnect.
Computer Architecture System Interface Units Iolanthe II approaches Coromandel Harbour.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6: Interrupts January 30 th Slides developed in part by Prof.
Computer Architecture Lecture 2 System Buses. Program Concept Hardwired systems are inflexible General purpose hardware can do different tasks, given.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
PHY 201 (Blum)1 Microcode Source: Digital Computer Electronics (Malvino and Brown)
SOC Consortium Course Material On Chip Bus National Taiwan University Adopted from National Taiwan University SOC Course Material.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 12: Memory and Peripheral Busses October 22nd, 2013 Slides.
Computer Organization CDA 3103 Dr. Hassan Foroosh Dept. of Computer Science UCF © Copyright Hassan Foroosh 2002.
ALU (Continued) Computer Architecture (Fall 2006).
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
Computer Architecture System Interface Units Iolanthe II in the Bay of Islands.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
Computer operation is of how the different parts of a computer system work together to perform a task.
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
CS 478: Microcontroller Systems University of Wisconsin-Eau Claire Dan Ernst Bus Protocols and Interfacing Bus basics I/O transactions MPC555 bus Reference:
Bus Protocols and Interfacing (adopted Steven and Marios’s slides) Bus basics I/O transactions MPC823 bus Reference: Chapter 13 of “White Book”
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 3: Toolchain, ABI, Memory Mapped I/O January 14 th, 2016 Slides.
MACHINE CYCLE AND T-STATE
Copyright © 2007 by Curt Hill Interrupts How the system responds.
Spring 2007W. Rhett DavisNC State UniversityECE 747Slide 1 ECE 747 Digital Signal Processing Architecture SoC Lecture – Working with Buses & Interconnects.
بسم الله الرحمن الرحيم MEMORY AND I/O.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 4: Review, Simulation, ABI, and Memory-Mapped I/O September.
10/15: Lecture Topics Input/Output –Types of I/O Devices –How devices communicate with the rest of the system communicating with the processor communicating.
Aditya Dayal M. Tech, VLSI Design ITM University, Gwalior.
Networked Embedded Systems Pengyu Zhang EE107 Spring 2016 Lecture 8 Serial Buses.
Programming and Debugging with the Dragon and JTAG Many thanks to Dr. James Hawthorne for evaluating the Dragon system and providing the core content for.
Presented By Aditya Dayal ITM University, Gwalior.
1 load [2], [9] Transfer contents of memory location 9 to memory location 2. Illegal instruction.
Slides developed in part by Mark Brehob & Prabal Dutta
Slides developed in part by Mark Brehob & Prabal Dutta
EE 107 Fall 2017 Lecture 7 Serial Buses – I2C Direct Memory Access
ME2100 EMBEDDED SYSTEM DESIGN (ARM9™) [Slide 8] ARM AMBA Bus BY DREAMCATCHER
Slides developed in part by Prof. Dutta
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
Burst read Valid high until ready high
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
Operating Systems Chapter 5: Input/Output Management
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Lecture 12 Input/Output (programmer view)
EECS 373 Design of Microprocessor-Based Systems Prabal Dutta
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 4: Bit of ssembly, Memory-mapped I/O, APB January 21, 2014

Today More assembly review Memory-mapped I/O Bus Architectures ARM AHB-Lite

Example call main: mov r0, #15 mov r1, #17 blx max loop: b loop min: push {r5} //not needed cmp r0, r1 it gt movgt r1, r0 pop {r5} bx lr Comments – I’ve left out some directives. – I’ve used an “it” (if-then) block makes the next instruction conditional Question – How to change to branch?

Reading the manual

Standard Assembler syntax fields

Push and Pop and the ABI

Today More assembly review Memory-mapped I/O Bus Architectures ARM AHB-Lite

Memory-mapped I/O The idea is really simple –Instead of real memory at a given memory address, have an I/O device respond. Huh? Example: –Let’s say we want to have an LED turn on if we write a “1” to memory location 5. –Further, let’s have a button we can read (pushed or unpushed) by reading address 4. If pushed, it returns a 1. If not pushed, it returns a 0. 9

Now… How do you get that to happen? –We could just say “magic” but that’s not very helpful. –Let’s start by detailing a simple bus and hooking hardware up to it. We’ll work on a real bus next time! 10

Basic example Discuss a basic bus protocol –Asynchronous (no clock) –Initiator and Target –REQ#, ACK#, Data[7:0], ADS[7:0], CMD CMD=0 is read, CMD=1 is write. REQ# low means initiator is requesting something. ACK# low means target has done its job.

A read transaction Say initiator wants to read location 0x24 A.Initiator sets ADS=0x24, CMD=0. B.Initiator then sets REQ# to low. (why do we need a delay? How much of a delay?) C.Target sees read request. D.Target drives data onto data bus. E.Target then sets ACK# to low. F.Initiator grabs the data from the data bus. G.Initiator sets REQ# to high, stops driving ADS and CMD H.Target stops driving data, sets ACK# to high terminating the transaction. I.Bus is seen to be idle.

Read transaction ADS[7:0] CMD Data[7:0] REQ# ACK# ?? 0x24 ?? 0x55 A B C D E F G HI

A write transaction (write 0xF4 to location 0x31) –Initiator sets ADS=0x31, CMD=1, Data=0xF4 –Initiator then sets REQ# to low. –Target sees write request. –Target reads data from data bus. (Just has to store in a register, need not write all the way to memory!) –Target then sets ACK# to low. –Initiator sets REQ# to high & stops driving other lines. –Target sets ACK# to high terminating the transaction

The push-button (if ADS=0x04 write 0 or 1 depending on button) ADS[7] ADS[6] ADS[5] ADS[4] ADS[3] ADS[2] ADS[1] ADS[0] REQ# Button (0 or 1) 0 Data[7] Data[0].. Delay ACK# Button (0 or 1)

The push-button (if ADS=0x04 write 0 or 1 depending on button) ADS[7] ADS[6] ADS[5] ADS[4] ADS[3] ADS[2] ADS[1] ADS[0] REQ# Button (0 or 1) 0 Data[7] Data[0].. Delay ACK# What about CMD?

The LED (1 bit reg written by LSB of address 0x05) ADS[5] ADS[7] ADS[6] ADS[4] ADS[3] ADS[2] ADS[1] ADS[0] REQ# Flip-flop which controls LED clock D DATA[5] DATA[7] DATA[6] DATA[4] DATA[3] DATA[2] DATA[1] DATA[0] Delay ACK#

Let’s write a simple assembly program Light on if button is pressed. 18

19 Outline Finish up example Bus Architectures ARM AHB-Lite

20 #include #define REG_FOO 0x main () { uint32_t *reg = (uint32_t *)(REG_FOO); *reg += 3; printf(“0x%x\n”, *reg); // Prints out new value } What happens when this “instruction” executes?

21 “*reg += 3” is turned into a ld, add, str sequence Load instruction –A bus read operation commences –The CPU drives the address “reg” onto the address bus –The CPU indicated a read operation is in process (e.g. R/W#) –Some “handshaking” occurs –The target drives the contents of “reg” onto the data lines –The contents of “reg” is loaded into a CPU register (e.g. r0) Add instruction –An immediate add (e.g. add r0, #3) adds three to this value Store instruction –A bus write operation commences –The CPU drives the address “reg” onto the address bus –The CPU indicated a write operation is in process (e.g. R/W#) –Some “handshaking” occurs –The CPU drives the contents of “r0” onto the data lines –The target stores the data value into address “reg”

22 Details of the bus “handshaking” depend on the particular memory/peripherals involved SoC memory/peripherals –AMBA AHB/APB NAND Flash –Open NAND Flash Interface (ONFI) DDR SDRAM –JEDEC JESD79, JESD79-2F, etc.

Modern embedded systems have multiple busses 23 Atmel SAM3U Historical 373 focus Expanded 373 focus

Advanced Microcontroller Bus Architecture (AMBA) - Advanced High-performance Bus (AHB) - Advanced Peripheral Bus (APB) AHB High performance Pipelined operation Burst transfers Multiple bus masters Split transactions APB Low power Latched address/control Simple interface Suitable of many peripherals 24

25 Actel SmartFusion system/bus architecture

Bus terminology Any given transaction have an “initiator” and “target” Any device capable of being an initiator is said to be a “bus master” –In many cases there is only one bus master (single master vs. multi-master). A device that can only be a target is said to be a slave device. Some wires might be shared among all devices while others might be point-to-point connections (generally connecting the master to each target). 26

Driving shared wires It is commonly the case that some shared wires might have more than one potential device that needs to drive them. –For example there might be a shared data bus that is used by the targets and the initiator. We saw this in the simple bus. –In that case, we need a way to allow one device to control the wires while the others “stay out of the way” Most common solutions are: –using tri-state drivers (so only one device is driving the bus at a time) –using open-collector connections (so if any device drives a 0 there is a 0 on the bus otherwise there is a 1) 27

Or just say no to shared wires. Another option is to not share wires that could be driven by more than one device... –This can be really expensive. Each target device would need its own data bus. That’s a LOT of wires! –Not doable when connecting chips on a PCB as you are paying for each pin. –Quite doable (though not pretty) inside of a chip. 28

Wire count Say you have a single-master bus with 5 other devices connected and a 32-bit data bus. –If we share the data bus using tri-state connections, each device has “only” 32-pins. –If each device that could drive data has it’s own bus… Each slave would need _____ pins for data The master would need ______ pins for data Again, recall pins==$$$$$$. 29

30 Outline Finish up example Bus Architectures ARM APB

31 APB is a fairly simple bus designed to be easy to work with. Low-cost Low-power Low-complexity Low-bandwidth Non-pipelined Ideal for peripherals

Let’s just look at APB writes (Master writing to device) as a starting point. We’ll add reads shortly. 32

Notation 33

APB bus signals PCLK –Clock PADDR –Address on bus PWRITE –1=Write, 0=Read PWDATA –Data written to the I/O device. Supplied by the bus master/processor. 34

APB bus signals PSEL –Asserted if the current bus transaction is targeted to this device PENABLE –High during entire transaction other than the first cycle. PREADY –Driven by target. Similar to our #ACK. Indicates if the target is ready to do transaction. Each target has it’s own PREADY 35

So what’s happening here?

Example setup For the next couple of slides, we will assume we have one bus master “CPU” and two slave devices (D1 and D2) –D1 is mapped to address 0x x F –D2 is mapped to 0x x F

Say the CPU does a store to location 0x with no stalls 38 D1 D2

Design a device which writes to a register whenever any address in its range is written 39 PWDATA[31:0] PWRITE PENABLE PSEL PADDR[7:0] PCLK PREADY 32-bit Reg D[31:0] Q[31:0] EN C We are assuming APB only gets lowest 8 bits of address here… What if we want to have the LSB of this register control an LED?

Reg A should be written at address 0x Reg B should be written at address 0x PWDATA[31:0] PWRITE PENABLE PSEL PADDR[7:0] PCLK PREADY 32-bit Reg A D[31:0] Q[31:0] EN C We are assuming APB only gets lowest 8 bits of address here… 32-bit Reg B D[31:0] Q[31:0] EN C

Reads… 41 The key thing here is that each slave device has its own read data (PRDATA) bus! Recall that “R” is from the initiator’s viewpoint—the device drives data when read.

Let’s say we want a device that provides data from a switch on a read to any address it is assigned. (so returns a 0 or 1) 42 PRDATA[31:0] PWRITE PENABLE PSEL PADDR[7:0] PCLK PREADY Mr. Switch

Device provides data from switch A if address 0x is read from. B if address 0x is read from 43 PRDATA[31:0] PWRITE PENABLE PSEL PADDR[7:0] PCLK PREADY Switch A Switch B

All reads read from register, all writes write… 44 PWDATA[31:0] PWRITE PENABLE PSEL PADDR[7:0] PCLK PREADY 32-bit Reg D[31:0] Q[31:0] EN C We are assuming APB only gets lowest 8 bits of address here…

Things left out… There is another signal, PSLVERR (APB Slave Error) which we can drive high if things go bad. –We’ll just tie that to 0. Notice we are assuming that our device need not stall. –We could stall if we needed. I can’t find a limit on how long, but I suspect at some point the processor would generate an error. 45

Verilog! 46

47 APB state machine IDLE –Default APB state SETUP –When transfer required –PSELx is asserted –Only one cycle ACCESS –PENABLE is asserted –Addr, write, select, and write data remain stable –Stay if PREADY = L –Goto IDLE if PREADY = H and no more data –Goto SETUP is PREADY = H and more data pending We’ll spend a bit more time on this next week…

48 Questions? Comments? Discussion?