1 / 16

Buffering: FIFO vs Double Buffering

Explore the advantages and considerations of using FIFO and double buffering for flow control protocols and data management in embedded systems. Learn about the benefits of modularizing applications using hierarchical states and virtual devices.

goodec
Download Presentation

Buffering: FIFO vs Double Buffering

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Topics • Business Matters • Read Simon Chapter 4 • Design Meeting • Some thought RAM might be easier than added SW Complexity … good point. Is it true? • Flow Control Protocol • Buffering: FIFO v. Double Buffering • Lab 2 • Play test sequence from ROM • Convert your own song (download from web) • http://www.knightvision.com/midis.html. • Play stream from workstation (Adam’s program)

  2. Wednesday’s Quiz • Basic Electronics • Our music format • Interfacing devices to 8051 • Memory Mapped Design • 8051 Ass’y and interrupts • Resource Utilization

  3. Example Buffering FIFO Or double buffer? Read Write

  4. FIFO Case • ISR • If (not empty) get item, move “tail” pointerelse what? • Main • If (not full) put item, move “head” pointerelse what? • When writing this code: • Assume ISR and MAIN are parallel processing running on separate computers using shared memory to communicate: why?

  5. FIFO • Empty Condition • Tail = Head • Tail is place to get next byte if != head • Initial Condition • Same as empty condition • Full Condition • Head = (Tail –1) • Head is place to put next byte if not right behind tail • Is there a bad time to get an interrupt?

  6. Example • Queue size is 10 • In Main if (next(head) != tail) { queue[head] = data; head = next(head); } unsigned char next(unsigned char) { head = head + 1 if (head) > 9 head = 0; } • Do we have a problem? • Solution?

  7. Double Buffering Case • When to switch buffers? • When write buffer is empty and read buffer is full? • What is the critical requirement for double buffering? • Why is it fine for video?

  8. Music Formats

  9. Midi conversion Input Resolution @120bpm = 2 qn/sec * 384u/qn = 768u/sec = 1.3ms/unit. Output resolution is: 20ms/ts /1.3ms/u = 15.36 u/timeslice To convert from input abs time to output abs time: divide by 15.36 and round off

  10. Midi conversion: Time signature ¾ time signature means: 3 quarter notes/beat?? If so: compute time to first event: Compute time to second event: Third event:

  11. Tracks and Channels mididmp time.mid > time.txt Encoding for First event? Second Event? Thirst Event? Fourth Event?

  12. mid2cse: .txt to .466 mid2cse time.txt 7 120 20 –2 time.466 | less

  13. More output

  14. The .466 File ff000000f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f801f8019801ff201d0c9801cf000000ff201d0cf8016801ff201b0cf8016801ff200e0cf8016801ff1d0d13f8016801cf1d0d16cf1c1613cf1d0d14cf1c1613cf200e0ccf1c1613ff1c16139801cf201d0cff201d0cf8016801ff201b0cf8016801ff1d0d14f8016801ff1d0d14f8016801ff201d0cf8016801ff1d0d16f8016801ff1c1613f8016801ff1c1613f8016801ff201d0cf8016801ff201d0cf8016801ff201b0cf8016801ff200e0cf8016801ff1d0d13f8016801cf1d0d16cf1c1613cf1d0d14cf1c1613cf200e0ccf1c1613ff1c16139801cf201d0cff201d0cf8016801ff201b0cf8016801ff1d0d14f8016801ff1d0d14f8016801ff201d0cf8016801ff1d0d16f8016801ff1c1613f8016801ff1c1613f8016801ff211d0cf8016801ff211c0cf8016801ff210e0cf8016801ff211d0cf8016801ff1d0e16f8016801ff1d0e15f8016801ff0e1611f8016801ff1c1613f8016801ff211d0cf8016801ff211c0cf8016801ff210e0cf8016801ff211d0cf8016801ff1d0e16f8016801ff1d0e15f8016801ff0e1611f8016801ff1c1613f8016801ff201d0cf8016801ff201d0cf8016801ff201b0cf8016801ff200e0cf8016801ff1d0d13f8016801cf1d0d16cf1c1613cf1d0d14cf1c1613cf200e0ccf1c1613ff1c16139801cf201d0cff201d0cf8016801ff201b0cf8016801ff1d0d14f8016801ff1d0d14f8016801ff201d0cf8016801ff1d0d16f8016801ff1c1613f8016801ff1c1613f8016801ff211d0cf8016801ff211c0cf8016801ff210e0cf8016801ff211d0cf8016801ff1d0e16f8016801ff1d0e15f8016801ff0e1611f8016801ff1c1613f8016801ff211d0cf8016801ff211c0cf8016801ff210e0cf8016801ff211d0cf8016801ff1d0e16f8016801ff1d0e15f8016801ff0e1611f8016801ff1c1613f8016801ff201d0cf8016801ff0c201df801f8013801ff0000009801ff0c201df801f8013801ff00000030016914fe0c20f801f8013801ff000000f82

  15. Embedded Software • Software States v. Finite State Machines • Hierarchical State • Thread/Process Communication • Critical Sections • Synchronization • Messaging and Signaling

  16. Benefits • Modularization of the Application • Some Virtual Machine Features • Device Drivers (Virtual Devices)

More Related