Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a small C program that does the following: Includes the library Creates a 16-bit unsigned value with any arbitrary initial value Performs the gray
Write a small C program that does the following:
- Includes the
library - Creates a 16-bit unsigned value with any arbitrary initial value
- Performs the gray code conversion on your 16-bit value
- Prints the output in binary
A couple of hints:
- Obviously you can't work with a C variable like a Verilog vector. The bit twiddling operations will be useful here. Moreover, the XOR operation will be a useful replacement for an operation that wasn't specified as XOR but has the same output.
- There is no printf() formatting specifier that prints in binary. Here is a really simple function you can borrow: void PrintBinary(uint16_t n) { uint16_t i = 0; for (i = 1 << 15; i > 0; i = i / 2) { (n & i) ? printf("1") : printf("0"); } printf(" "); return; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started