Search Results For : uni

Converting Binary to Gray Codes

I am doing one of the tutorial in CS2100 in NUS SoC and one of the questions require us to convert between binary and gray codes.

I have decided to write a simple tutorial on how to convert from binary to gray codes.

What is Gray Code?
“….is a binary numeral system where two successive values differ in only one bit. The reflected binary code was originally designed to prevent spurious output from electromechanical switches.”
~http://en.wikipedia.org/wiki/Gray_code

What is Binary Code?
A binary code represents text or computer processor instructions using the binary number system’s two binary digits, 0 and 1.
~http://en.wikipedia.org/wiki/Binary_code

Before we start, lets look at an Exclusive OR, XOR(sometimes EOR gate, or EXOR gate)’s truth table.

The whole concept on how to do the conversion between the 2 number system heavily uses the XOR truth table.

 

 

 

Binary to Gray Code Conversion

Binary to Gray Code Conversion : Step 1 – Prepare a table like this

Binary to Gray Code Conversion

Binary to Gray Code Conversion : Step 2 – Copy down the Most Significant Bit (MSB) of Binary onto Gray Code row

Binary to Gray Code Conversion

Binary to Gray Code Conversion : Step 3 – Get the MSB and next MSB of Binary and XOR them and copy its result down

Binary to Gray Code Conversion

Binary to Gray Code Conversion : Step 4 – Get the MSB and next MSB of Binary and XOR them and copy its result down

Binary to Gray Code Conversion

Binary to Gray Code Conversion : Step 5 – Get the MSB and next MSB of Binary and XOR them and copy its result down

Binary to Gray Code Conversion

Binary to Gray Code Conversion : Step 6 – Get the MSB and next MSB of Binary and XOR them and copy its result down

Binary to Gray Code Conversion

Binary to Gray Code Conversion : Step 7 – Get the MSB and next MSB of Binary and XOR them and copy its result down

Binary to Gray Code Conversion

Binary to Gray Code Conversion : Step 8 – Get the MSB and next MSB of Binary and XOR them and copy its result down

Gray Code to Binary Conversion

Gray Code to Binary Conversion : Step 1 – Prepare a table like this

Gray Code to Binary Conversion

Gray Code to Binary Conversion : Step 2 – Copy up the Most Significant Bit (MSB) of Gray Code onto Binary row

Gray Code to Binary Conversion

Gray Code to Binary Conversion : Step 3 – Take the MSB of Binary and next most MSB of Gray Code and XOR them. Copy its result upwards.

Gray Code to Binary Conversion

Gray Code to Binary Conversion: Step 4 – Take the MSB of Binary and next most MSB of Gray Code and XOR them. Copy its result upwards.

Gray Code to Binary Conversion

Gray Code to Binary Conversion: Step 5 – Take the MSB of Binary and next most MSB of Gray Code and XOR them. Copy its result upwards.

Gray Code to Binary Conversion

Gray Code to Binary Conversion: Step 6 – Take the MSB of Binary and next most MSB of Gray Code and XOR them. Copy its result upwards.

Gray Code to Binary Conversion

Gray Code to Binary Conversion: Step 7 – Take the MSB of Binary and next most MSB of Gray Code and XOR them. Copy its result upwards.

Gray Code to Binary Conversion

Gray Code to Binary Conversion: Step 8- Take the MSB of Binary and next most MSB of Gray Code and XOR them. Copy its result upwards.

Studying in National University of Singapore

Its been a month plus since I ORD’ed and matriculated into National University of Singapore(NUS). You can refer to my ORD post here (ORD LO). Week 0 was on 5 August 2013 and our official lessons started a week later on 12 August 2013. First 2 weeks are purely just lectures and sectional teaching(just like lectures) and during these 2 weeks, we are bidding for our tutorials and lab slots. This semester is 13 weeks long for me(inclusive of 1 week eLearning and 1 week recess week(on week 7)).

In my first semester of year 1, I took the following modules.

  1. MA1301 – INTRODUCTORY MATHEMATICS
  2. CS1020 – DATA STRUCTURES AND ALGORITHMS I
  3. CS2100 – COMPUTER ORGANISATION
  4. IS1105 – STRATEGIC IT APPLICATIONS
  5. SSA2209 – GOVERNMENT AND POLITICS OF SINGAPORE

Besides CS2100 which I spent 211 points to bid for it from my Programme Account and SSA2209 which I spent 50 points. The rest were pre-allocated and 1 points for each were deducted from my Programme Account. Its interesting how we have to fight for the modules that we would want to take. This is something very different from what we have in polytechnic.

I am entering week 5, which is the e-learning week for this semester. I would say that the whole ecosystem of NUS is very different from Temasek Polytechnic. No more caregroup system, you are now “given more responsibility” for your own education. No more checking of homework by tutors, if you do not participate actively in class and finish up the tutorials, you are going to pile up your backlogs and before you know it, its already exam.

To end off, some useful links that would benefit a new student or existing undergraduate.

Useful links
NUS MyISIS
NUS IVLE
NUS Email Login
NUS SoC Email Login
NUS CORS
NUS SoC CodeCrunch
NUSMods
SoC Undergraduates – Useful Course Schedule
NUS Library Portal
NUS Library Portal – Exam Papers
uTown Facilities Booking
Will update this blog more often! Time to change a theme!