EECS 373 Design of Microprocessor-Based Systems Mark Brehob

Slides:



Advertisements
Similar presentations
Digital Logic issues in Embedded Systems. Things upcoming Remember that the first two topic talks are on 10/24 (ultrasonic distance and stepper motors)
Advertisements

Day of Miscellany ADC/DAC I2C Student presentations.
Assume array size is 256 (mult: 4ns, add: 2ns)
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 8: Clocks, Counters, Timers, Capture, and Compare September.
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
Binary Arithmetic Math For Computers.
Rabie A. Ramadan Lecture 3
© BYU 18 ASYNCH Page 1 ECEn 224 Handling Asynchronous Inputs.
Digital Logic Design Lecture # 21 University of Tehran.
ENG241 Digital Design Week #8 Registers and Counters.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Serial buses, digital design Material taken from Dutta, Le, Ramadas,
EE3A1 Computer Hardware and Digital Design Lecture 9 Pipelining.
Digital Design - Sequential Logic Design
Combinational circuits
Lecture 10 Flip-Flops/Latches
Dr. Clincy Professor of CS
Homework Reading Machine Projects Labs Tokheim Chapter 9.1 – 9.6
Registers and Counters
Flip Flops Lecture 10 CAP
Clocks A clock is a free-running signal with a cycle time.
Introduction to Registers
EN 001-4: Introduction to Computational Design
Instructor: Alexander Stoytchev
Registers and clocking issues
Minimization and Sequential Logic
CS Chapter 3 (3A and ) – Part 4 of 5
ECE Digital logic Lecture 16: Synchronous Sequential Logic
332:437 Lecture 12 Finite State Machine Design
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
Inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #21 State Elements: Circuits that Remember Hello to James Muerle in the.
How does the CPU work? CPU’s program counter (PC) register has address i of the first instruction Control circuits “fetch” the contents of the location.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN
Dr. Clincy Professor of CS
CSE 370 – Winter Sequential Logic - 1
Lecture 15 Logistics Last lecture Today HW4 is due today
Lecture 16 Logistics Last lecture Today HW5 out, due next wednesday
EECS 373 Design of Microprocessor-Based Systems A day of Misc. Topics
332:437 Lecture 8 Verilog and Finite State Machines
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Flip-Flops Last time, we saw how latches can be used as memory in a circuit. Latches introduce new problems: We need to know when to enable a latch. We.
EECS150 Fall 2007 – Lab Lecture #4 Shah Bawany
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
Guest Lecture by David Johnston
Latches The second part of CS231 focuses on sequential circuits, where we add memory to the hardware that we’ve already seen. Our schedule will be very.
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
Instructor: Alexander Stoytchev
Lecture 16 Logistics Last lecture Today HW5 out, due next wednesday
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
Flip-Flops.
ECE 352 Digital System Fundamentals
Sequential circuit analysis
Homework Finishing Chapter 2 of K&R. We will go through Chapter 3 very quickly. Not a lot is new. Questions?
Lecture 19 Logistics Last lecture Today
ECE 352 Digital System Fundamentals
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
EGR 2131 Unit 12 Synchronous Sequential Circuits
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
332:437 Lecture 8 Verilog and Finite State Machines
Sequential Digital Circuits
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
Instructor: Michael Greenbaum
Presentation transcript:

EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 13: Wrapping up and moving forward. Review error with ADCs/DACs Finish design rules Quick discussion of MMIO in C

Student talk assignments coming out today. Announcements HW5 due Tuesday Oct 23rd. Student talk assignments coming out today. Wednesday in class is a review session Just questions and answers If you don’t have questions it will be very short. I expect most questions will come from old exams and homework assignments. Exam is 6:30pm on Wednesday in IOE1610.

Analog conversion errors review

Ideal transfer function Quantization error Ideal transfer function Ideal transfer with ½ LSB offset Here we take all values from 0 to ⅛ and call them “000”. Here we shift over the value by ½ LSB. This means the ideal transfer function and the actual one are never more than ½ LSB (1/16 in this case) off. http://www.embedded.com/showArticle.jhtml?articleID=60403334

Integral nonlinearity The integral nonlinearity (INL) is the deviation of an ADC's transfer function from a straight line. This line is often a best-fit line among the points in the plot but can also be a line that connects the highest and lowest data points, or endpoints. INL is determined by measuring the voltage at which all code transitions occur and comparing them to the ideal. The difference between the ideal voltage levels at which code transitions occur and the actual voltage is the INL error, expressed in LSBs. INL error at any given point in an ADC's transfer function is the accumulation of all DNL errors of all previous (or lower) ADC codes, hence it's called integral nonlinearity.

Differential nonlinearity DNL is the worst cases variation of actual step size vs. ideal step size. It’s a promise it won’t be worse than X.

Digital design

Glitches x y z Full adder (from Wikipedia) Consider the adjacent circuit diagram. Assuming the XOR gates have a delay of 0.2ns while AND and OR gates have a delay of 0.1ns, fill in the following chart. Only selected causality arrows shown…

Glitching: a summary When input(s) change The output can be wrong for a time However, that time is bounded And more so, the output can change during this “computation time” even if the output ends up where it started!

Effect of Glitches Think back to EECS 370. Why don’t glitches cause errors? The trick is that the inputs all change at the same time In this case, the ID/EX registers all change some time shortly after the rising edge of the clock. And we’ve chosen the clock period such that the next edge doesn’t happen until the combinational logic has stopped glitching. In fact, we use the worst-case combinational logic delay in the whole system when determining the clock period! Note the animation here. I didn’t want the text to show up on the printed slides.

So, how can glitches hurt us? There are a handful of places: Asynchronous resets If you’ve got a flip-flop that has an asynchronous reset (or “preset”) you need to be sure the input can’t glitch. That pretty much means you need a flip-flop driving the input (which means you probably should have used a sync. reset!) Clocks If you are using combinational logic to drive a clock, you are likely going to get extra clock edges. Traditionally, CLR is used to indicate async reset. “R” or “reset” for sync. reset. If clk is high and cond glitches, you get extra edges!

X X Design rules Thou shalt not use asynchronous resets Thou shalt not drive a clock with anything other than a clock or directly off of a flip-flop’s output X

Really? Seriously? People do use asynchronous resets and clock gating! Yep. And people use goto in C programs. Sometimes they are the right thing. But you have to think really hard about them to insure that they won’t cause you problems. Our “simple” bus used combinational logic for the clock Works because REQ goes low only after everything else has stopped switching So no glitch. Not fun to reason about… Avoid unless you must Then think really carefully.

Setup and hold time The idea is simple. When the clock is changing if the data is also changing it is hard to tell what the data is. Hardware can’t always tell And you can get meta-stable behavior too (very unlikely but…) So we have a “guard band” around the clock rising time during which we don’t allow the data to change. See diagram. We call the time before the clock-edge “setup time” and the time after “hold time” Using dropping erasers thing. Drop 2 erasers, ask which hit first. The point being that it can be hard to tell even though they didn’t happen at the same time (no two things do). Makes sense we want some type of band around when the clock is changing so that the data isn’t so we grab the right thing.

So what happens if we violate set-up or hold time? Often just get one of the two values. And that often is just fine. Consider getting a button press from the user. If the button gets pressed at the same time as the clock edge, we might see the button now or next clock. Either is generally fine when it comes to human input. But bad things could happen. The flip-flop’s output might not settle out to a “0” or a “1” That could cause later devices to mess up. More likely, if that input is going to two places, one might see a “0” the other a “1” Important: don’t feed an async input to multiple places!

A common thing to do is reset a state machine using a button. Example A common thing to do is reset a state machine using a button. User can “reset” the system. Because the button transition could violate set-up or hold time, some state bits of the state machine might come out of reset at different times. And you quickly end up at a wrong or illegal state. Insert story about the E100 here.

Dealing with inputs not synchronized to our local clock is a problem. So… Dealing with inputs not synchronized to our local clock is a problem. Likely to violate setup or hold time. That could lead to things breaking. So we need a clock synchronization circuit. First flip-flop might have problems. Second should be fine. Sometimes use a third if really paranoid Safety-critical system for example. Figure from http://www.eeweb.com/electronics-quiz/solving-metastability-design-issues, we use the same thing to deal with external inputs too!

Design rules  Thou shalt use a clock synchronization circuit when changing clock domains or using unclocked inputs! /* Synchonization of Asynchronous switch input */ always@(posedge clk) begin sw0_pulse[0] <= sw_port[0]; sw0_pulse[1] <= sw0_pulse[0]; sw0_pulse[2] <= sw0_pulse[1]; end Code from lab 3 and from http://www.fpga4fun.com/SPI2.html always @(posedge clk) SSELr <= {SSELr[1:0], SSEL}; Also, be aware most FPGA libraries have resources to make dealing with multiple clock domains easier. Bi-directional queues generally.

MMIO review

Talking to MMIO locations via C. Write a C function “clear_and_enable” which takes a single external interrupt source as an argument. It clears the pending status for that register and enables interrupts from that source. It should return a 1 if the source was already enabled, otherwise it should return a 0. You need not check to see if x is a reasonable value.

So, what do we want to do? Idea (in English): Pseudo code:

Let’s do it wrong. int clear_and_enable(int x) { int *s_en =0xE000E100; int *c_pend =0xE000E280; int index =x>>5; int offset =x & 5’b11111; int mask =1<<offset; int estatus =*(s_en+index) & mask; *(c_pend+index)&=mask; // clear pending if(estatus) //(would estatus==1 work here?) return(1); *(s_en+index)|=mask; // set enable return(0); } (errors are described in the pptx notes) Constants as pointers need a cast MMIO locations should always be volatile When working with bitmasks should always have them as unsigned as signed values may have unexpected behaviors The 5’b11111 is Verilog, not C. Gcc and C++14 do support 0b11111 as does nearly every other C complier, so it has a chance. 0x1f is a better choice for C programs. %32 also works here. The index stuff is right due to pointer math rules. &= and |= are both bad. |= is a lot worse. Why?

Now try to do it right (without looking!)