Project Checkoff 2 UART Design Jeffrey Tsai Project

  • Slides: 26
Download presentation
Project Check-off 2 UART Design Jeffrey Tsai

Project Check-off 2 UART Design Jeffrey Tsai

Project Thus Far Main Control FSM Collision SRAM Packet Logic UART IN FIFO UART

Project Thus Far Main Control FSM Collision SRAM Packet Logic UART IN FIFO UART OUT FIFO Audio Out interface Audio In interface

UART n n n Message Definition Super-sampling Receiver Implementation Transmitter Implementation Xilinx and Debugging

UART n n n Message Definition Super-sampling Receiver Implementation Transmitter Implementation Xilinx and Debugging tips (time permitting)

Message Definition n n A low start bit followed by 8 data bits and

Message Definition n n A low start bit followed by 8 data bits and a high stop bit. (clock is 250 k. Hz) The wire is normally high. TX Idle Start D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 Stop Idle TX_E Time Figure 3: A UART transmission.

Super-Sampling n n We watch the incoming wire at 8 times the send rate.

Super-Sampling n n We watch the incoming wire at 8 times the send rate. (2 MHz) This makes it so we can catch a 250 Khz message even if its phase is different from our internal 250 KHz clock. Sample Here Serial data input

Receiver Implementation n Nick Weaver’s UART – Receive design. Inputs: Serial-In, Reset, Clock Outputs:

Receiver Implementation n Nick Weaver’s UART – Receive design. Inputs: Serial-In, Reset, Clock Outputs: D[7: 0], DRDY (data-ready) SERIAL-IN. H UART OE. L D[7: 0] DRDY. H RESET. H Clock

How do I start? !? n n If the incoming message is 10 bits

How do I start? !? n n If the incoming message is 10 bits in length, and we super-sample at 8 x, the message is complete when we receive 80 bits of data. How do we keep track of where I am in the message?

8 -bit Binary Counter n n 3 Inputs to figure out : R, CE,

8 -bit Binary Counter n n 3 Inputs to figure out : R, CE, C CE is on as long as you are receiving a new message C is the super-sampled clock frequency, NOT the incoming baud rate R is used to reset the counter once the message is complete

Count Enable n n n Should be high when the input initially drops low

Count Enable n n n Should be high when the input initially drops low for the start bit. Should stay high for the duration of the message by means of a PROCEED signal. CE = INPUT’ + PROCEED

Clock n n You’ve seen how to divide clocks already from previous labs. The

Clock n n You’ve seen how to divide clocks already from previous labs. The clock that’s available on the board already (not from the Xchecker) is 16 MHz. Use a binary counter to divide it. Sticky point: You send at 250 k. Hz, you sample at 2 MHz, your circuit needs one faster than that. Probably 8 MHz.

Reset n n Should be reset when the counter enable is low. When the

Reset n n Should be reset when the counter enable is low. When the RESET button on the board is pressed, the counter should reset. When the message is done, and DRDY goes high (data ready), this should be reset for safety/reliability reasons. R = CE’ + RESET + DRDY

PROCEED n n Intuitively, it should catch the first super -sampled bit, and stay

PROCEED n n Intuitively, it should catch the first super -sampled bit, and stay high for the duration of the message. This should be done with a flip-flop. PROCEED = INPUT’ + PROCEED But we sample from the middle of each signal, so instead, we use Q 2 (3 rd bit from right of the counter)

There’s more! n n n But this feedback loop will loop high forever! So

There’s more! n n n But this feedback loop will loop high forever! So when DRDY or RESET is asserted, PROCEED must be forced low. PROCEED = DRDY’ RESET’ (Q 2+PROCEED)

Proceed (cont. )

Proceed (cont. )

Shift Register n n Inputs the data serially and outputs it to the rest

Shift Register n n Inputs the data serially and outputs it to the rest of our design in a parallel fashion. All we need to determine is CE for the shift register. Since we sample on the forth supersample per sample, just look at counter. CE = Q 0’ Q 1’ Q 2

Why just the last 3 bits? n n n 4 = 00000100 12 =

Why just the last 3 bits? n n n 4 = 00000100 12 = 00001100 20 = 00010100 28 = 00011100 36 = 00100100 Etc.

When do we stop? n n n This design uses a 8 -bit shift

When do we stop? n n n This design uses a 8 -bit shift register to save space. Thus, we don’t want the stop bit to be shifted in. We want to stop at 9*8+3 = 75 75= 01001011 DRDY = Q 6 Q 3 Q 2’ Q 1 Q 0 UART-RECEIVE IS DONE!

UART-RECEIVE SUMMARY n n n 8 Bit counter: CE = INPUT’ + PROCEED R

UART-RECEIVE SUMMARY n n n 8 Bit counter: CE = INPUT’ + PROCEED R = CE’ + RESET + DRDY C = 2 MHz Clk Proceed: PROCEED = DRDY’ RESET’ (Q 2+PROCEED) Shift Register: CE = Q 0’ Q 1’ Q 2 DRDY = Q 6 Q 3 Q 2’ Q 1 Q 0

UART-RECEIVE (cont) n n n Do not take this for granted! I defined the

UART-RECEIVE (cont) n n n Do not take this for granted! I defined the important signals, the rest are trivial. Make sure you UNDERSTAND the design rather than just plugging it in!

What about transmit? n Well, you tell me. Transmittin g SERIAL-OUT. H (TX) UART

What about transmit? n Well, you tell me. Transmittin g SERIAL-OUT. H (TX) UART / TX D[7: 0] SEND. H OUTPUT_ENABLE (TX_E) RESET. H Clock Figure 2: UART Transmitter symbol.

Specs for UART-Transmit n n n The signal you send must comply with our

Specs for UART-Transmit n n n The signal you send must comply with our message definition. A interrupt input (reset) is needed so back-off is possible. (remember that in the project, if what you read back isn’t what you wrote, you must stop transmitting) Need TX_E to be high while transmitting and low otherwise.

General Tips n n n KISS (keep it simple stupid) If you have no

General Tips n n n KISS (keep it simple stupid) If you have no clue what your circuit does, chances are, neither does anyone else. Don’t be afraid to play around with the signals in a way that makes it easy for you to debug. Learn to use the oscilloscope!

Playing with bus wires n n n A complicated bus lets you combine multiple

Playing with bus wires n n n A complicated bus lets you combine multiple wires together to form a bus. Remember that a bus is just a collection of wires! Useful if you a bunch of signals that aren’t named to same into a bus.

Bus wires (cont. ) n n Notice the Simple Box on top right is

Bus wires (cont. ) n n Notice the Simple Box on top right is unchecked (its checked by default) Now I can specify each signal individually. Separate each one by comma.

Bus wires (cont. )

Bus wires (cont. )

That’s All! n Good luck and start early!

That’s All! n Good luck and start early!