Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP WITH THE FOLLOWING PROBLEM. I DONT EVEN KNOW HOW TO BEGIN TO ANSWER THESE QUESTIONS. I WILL BE BEYOND GRATEFUL IF SOMEONE CAN

PLEASE HELP WITH THE FOLLOWING PROBLEM. I DONT EVEN KNOW HOW TO BEGIN TO ANSWER THESE QUESTIONS. I WILL BE BEYOND GRATEFUL IF SOMEONE CAN PROVIDE THE ANSWER.

THE CODE BELOW IS WRITTEN IN VERILOG

Simple Loopback System:

Consider a simple loopback system as in Fig. 1. In such a setup, a PC can send a message which is returned (looped) back to PC by the processor. Such a loopback test is helpful to test if the processor is alive or not. A PC (not shown) interfaces with PicoBlaze processor using an RS232 (serial) connection. Let us examine the case when the PC acts as a transmitter. In this case the data arrives serially on RS232_RX line. But we know that PicoBlaze accepts only byte-size data. So we need to convert the serial data into parallel (8-bit) data. In such a case, a UART (Universal Asynchronous Receiver Transmitter) block can help. UART_RX does the serial-to-parallel conversion, i.e., the data arriving on RS232_RX line is buffered in a 16-byte buffer. Whenever new data is presented on rx_data output, UART_RX will assert data_present, i.e., data_present = 1 in other words data_present validates rx_data. The Input Port Logic block consists of glue logic that connects UART_RX to the IN_PORT. After PicoBlaze reads the data, it can request the next data item by asserting read_from_uart signal. Now, let us consider the case when PicoBlaze acts as a transmitter i.e., PC is the receiver. In this case, PicoBlaze puts out 8-bit data while PC is expecting serial data. Again, UART (UART_TX in Fig. 1) comes to our rescue! The output bus with id=3 is connected to UART_TX. Output Port Logic block interfaces PicoBlaze with LEDs and UART_TX

image text in transcribed

In this system, we can also manually provide 8-bit data via 8 switches (switches bus in Fig. 1). PicoBlaze can write 8-bit data to drive 8 leds (leds bus in Fig. 1). Recall that PicoBlaze can accept up to 256 input ports each of which can addressed by 8-bit PORT_ID bus. Similarly, it can drive up to 256 ports and the address of the port being driven appears on PORT_ID bus. In Fig. 1, for example, the id of the input port, switches, is 0. Similarly, the rx_data has id of 2. The port ids are shown in bold font in the Fig. 1. The high-level views of UART in transmit and received modes are shown in Fig. 2.

Answer the following questions:

a) Explain under what condition(s) should the following signals be asserted?

i. read_from_uart

ii. write_to_uart

b) cold_start: Explain the code below to output a message Welcome to Loopback! to the serial port.

cold_start: load s0, s0; //NOP

Load s0, ascii_W

Store s0, 00

Load s0, ascii_E

Store s0, 01

.

Load s0, ascii_k

Store s0, 12

Load s0, ascii_EXCLAIM

Store s0, 13 //Scratch pad memory addresses are in HEX

image text in transcribed

c) led_echo and rs232_echo: Explain the code below to read switches and write it, inverted, to the LEDs. Explain the code below to check if a byte has been received by UART_RX. If so, send it back to PC via UART_TX.

image text in transcribed

PicoBlaze Microcontroller switches leds Output Port Logic 3 OUT-PORT 01 RS232 RX Input INTERRUPT RESET 8 UARTRS232 TX UART data 2 Pot ata presen PORT-op READ STROBE WRITE STROB INTERRUPT TX CLK CLK CLK write to uart read from ua read strobe buffer full Figure 1: A simple loopback system UART TX UART RX 8-bit 8-bit Serial Serial 16 Byte FIFO Buffer 16 Byte FIFO Buffer TX RX Figure 2: UARTTransmit and Receive Blocks - High Level View Note that for the sake of clarity, we have not shown the clock and reset signal connections. main: xor s0, s0 INDEX TO LOOP THROUGH ADDRESSES next letter: input s3, buffer_full compare s3, 01 jump z, buffer full cal1 fetch sl, (s0) add s0, 01 ;CHECK IF BUFFER IS FULL JUMP IF UART TX FULL ;FE CH NEXT LETTER AND THEN INCREMENT ADDRESS ready buffer: output sl, uart data tx compare s0, 14 ump nz, next letter jump led_echo OUTPUT LETTER TO UART_TX CHECK IF HE REACHED END OF MESSAGE TO END JUMP TO LED ECHO buffer full call: load sF, SF jump next letter BUFFER FULL STALL JUMP BACK AND RE-CHECR BUFFER FULL led echo: s0, s0 ; (nop) TAKE INPUT FROM SHITCHES AND RETURN INVERTED TO LEDS LOAD input s0, switches xor s0, FF output s, leds jump rs232_echo JUMP TO RS232 ECHO rs232 echo: so, s0 LOAD xor sl,sl xor 52, s2 input sl, uart_data xx input s2, data_present compare s2, 01 jump z, send bac.k : (nop) CLEAR S1 CLEAR S2 ,READ FROM RX AND STORE IN SI ;CHECK IF DATA PRESENT FOR RX IF DATA PRESENT JUMP TO SEND BACK jump led_echo IF NO DATA PRESENT KEEP WAITING send back: output si, uart_data_tx jump led_echo OUTPUT Si TO TX JUMP BACK TO LED ECHO PicoBlaze Microcontroller switches leds Output Port Logic 3 OUT-PORT 01 RS232 RX Input INTERRUPT RESET 8 UARTRS232 TX UART data 2 Pot ata presen PORT-op READ STROBE WRITE STROB INTERRUPT TX CLK CLK CLK write to uart read from ua read strobe buffer full Figure 1: A simple loopback system UART TX UART RX 8-bit 8-bit Serial Serial 16 Byte FIFO Buffer 16 Byte FIFO Buffer TX RX Figure 2: UARTTransmit and Receive Blocks - High Level View Note that for the sake of clarity, we have not shown the clock and reset signal connections. main: xor s0, s0 INDEX TO LOOP THROUGH ADDRESSES next letter: input s3, buffer_full compare s3, 01 jump z, buffer full cal1 fetch sl, (s0) add s0, 01 ;CHECK IF BUFFER IS FULL JUMP IF UART TX FULL ;FE CH NEXT LETTER AND THEN INCREMENT ADDRESS ready buffer: output sl, uart data tx compare s0, 14 ump nz, next letter jump led_echo OUTPUT LETTER TO UART_TX CHECK IF HE REACHED END OF MESSAGE TO END JUMP TO LED ECHO buffer full call: load sF, SF jump next letter BUFFER FULL STALL JUMP BACK AND RE-CHECR BUFFER FULL led echo: s0, s0 ; (nop) TAKE INPUT FROM SHITCHES AND RETURN INVERTED TO LEDS LOAD input s0, switches xor s0, FF output s, leds jump rs232_echo JUMP TO RS232 ECHO rs232 echo: so, s0 LOAD xor sl,sl xor 52, s2 input sl, uart_data xx input s2, data_present compare s2, 01 jump z, send bac.k : (nop) CLEAR S1 CLEAR S2 ,READ FROM RX AND STORE IN SI ;CHECK IF DATA PRESENT FOR RX IF DATA PRESENT JUMP TO SEND BACK jump led_echo IF NO DATA PRESENT KEEP WAITING send back: output si, uart_data_tx jump led_echo OUTPUT Si TO TX JUMP BACK TO LED ECHO

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions