Question

Table : CPLD USER_REG Register Bit Name R/W Description 7 USER_SW3 User DIP Switch 311 = Off(UP), 0 = On(DOWN)) 6 USER_SW2 Us

Try to find out what happens when we press down or up of switch 3? (Please refer to the picture given)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

From the given image we can understand that USER_REG is an 8-bit register whose upper 4 bits are the state of four dip switches. We will begin by understanding the condition present in the if statement.

The condition given to the if statement is (USER_REG >> 4) & (0x8). This checks if the bit in position 7 is 1 or 0. It does this as follows:

USER_REG consists of the following bits in the following positions:

7th USER_SW3
6th USER_SW2
5th USER_SW1
4th USER_SW0
3rd USER_LED3
2nd USER_LED2
1st USER_LED1
0th USER_LED0

USER_REG >> 4 shifts the 8-bit number to the right by four positions.

(USER_REG >> 4) is a new number that consists of the following bits (the four new freed up positions are filled up with 0):

7th 0
6th 0
5th 0
4th 0
3rd USER_SW3
2nd USER_SW2
1st USER_SW1
0th USER_SW0

(USER_REG >> 4) & (0x8) checks the 3rd bit position in (USER_REG >> 4) if its 0 or 1. It does this as follows:

(USER_REG >> 4) & (0x8) = (USER_REG >> 4) & (0b00001000) = USER_SW3 & 1

Which is true only when USER_SW3 is 1.

Based on this understanding we can see that when the switch is down (USER_SW3 == 1), the if clause is executed and the input is copied to the output. Similarly, when the switch is up (USER_SW3 == 0), the else clause is executed and the function dsp_process is called.

Please leave a positive rating if the answer is satisfactory or leave a comment if more explanation is needed.

Add a comment
Know the answer?
Add Answer to:
Try to find out what happens when we press down or up of switch 3? (Please...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, I have some errors in my C++ code when I try to debug it. I...

    Hello, I have some errors in my C++ code when I try to debug it. I tried to follow the requirements stated below: Code: // Linked.h #ifndef INTLINKEDQUEUE #define INTLINKEDQUEUE #include <iostream> usingnamespace std; class IntLinkedQueue { private: struct Node { int data; Node *next; }; Node *front; // -> first item Node *rear; // -> last item Node *p; // traversal position Node *pp ; // previous position int size; // number of elements in the queue public: IntLinkedQueue();...

  • You've been hired by Rugged Robots to complete a C++ console application that controls a robotic...

    You've been hired by Rugged Robots to complete a C++ console application that controls a robotic floor vacuum. Wayne State software engineers have already developed the following three files: File Description Lab20-01-Key.cpp This is the user application. RuggedRobotLibrary.h This is the library header file. It contains constant declarations and function prototypes. It is included by the other two files. RuggedRobotLibrary.cpp This is the library file. It contains functions that may be used in any user application. This is considered an...

  • Can you please help me with creating this Java Code using the following pseudocode? Make Change C...

    Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.)                                                                                                                                  2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...

  • C+ HelloVisualWorld, pages 121-125 (in the 3-6 Deciding Which Interface to Use Section) We were unable...

    C+ HelloVisualWorld, pages 121-125 (in the 3-6 Deciding Which Interface to Use Section) We were unable to transcribe this imageCHAPTER 3 Using Guy Objects and the Visual Studio IDE Using Gul Objects (continued) Forn click the Form, its Properties window appears in the lower right portion of the screen, and you can see that the Text property for the Form IS set to Forml. Take a moment to scroll through the list in the Properties Window, examining the values of...

  • I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this p...

    I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this paper and some conclusions and contributes of this paper. I need this for my Finishing Project so i need this ASAP please ( IN 1-2-3 HOURS PLEASE !!!) Budgetary Policy and Economic Growth Errol D'Souza The share of capital expenditures in government expenditures has been slipping and the tax reforms have not yet improved the income...

  • Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around...

    Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around risk and threat management, fostering an environment in which objectives seem clear: manage risk, manage threat, stop attacks, identify attackers. These objectives aren't wrong, but they are fundamentally misleading.In this session we'll examine the state of the information security industry in order to understand how the current climate fails to address the true needs of the business. We'll use those lessons as a foundation...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT