Question

In: Computer Science

Part (a): Computing odd parity Digital-communication hardware and software often include circuitry and code for detecting...

Part (a): Computing odd parity

Digital-communication hardware and software often include circuitry and code for

detecting errors in data transmission. The possible kinds of errors are large in

number, and their detection and correction is sometimes the topic of upper-level

Computer Science courses. In a nutshell, however, the concern is that bits sent by a

data transmitter are sometimes not the same bits that arrive at the data receiver.

That is, if the data transmitter sends this word:

0x00200020

but this is received instead:

0x00204020

then the data receiver has the wrong data, and would need some way to determine

that this was the case. In response to the error, the same receiver might discard the

word, or ask the sender to retransmit it, or take some other combination of steps.

A technique for detecting one-bit errors is to associate with each word a parity bit . If

an odd parity bit is transmitted along with the word, then the number of all set bits in

the word plus the value of the parity bit must sum to an odd number . In our example

above involving the data transmitter, the chosen parity bit would be 1 (i.e., two set

bits in 0x00200020 , plus one set parity bit, equals three set bits). The data receiver

has the corrupted byte as shown ( 0x00204020 ) plus the parity bit value, and

determines that the number of set bits is four(i.e., three bits in the word, plus the set

parity bit, resulting in four set bits, which is an even number). Given that four is not

an odd number, the receiver can conclude there was an error in transmission. Note

that the receiver can only detect an error with the parity bit; more is needed to

correct the error. (Also notice that if two bits were in error, then our scheme would

not detect this event.)

Your main task for part (a) is to complete the code in the file named parity.asm

that has been provided for you. You must also draw by hand the flowchart of your

solution and submit a scan or smartphone photo of the diagram as part of your

assignment submission; please ensure this is a JPEG or PDF named

“ parity_flowchart.jpg ” or “ parity_flowchart.pdf ” depending on the file

format you have chosen.

Some test cases are provided to you.

# Compute odd parity of word that must be in register $8
# Value of odd parity (0 or 1) must be in register $15


.text

start:
        lw $8, testcase1  # STUDENTS MAY MODIFY THE TESTCASE GIVEN IN THIS LINE
        
# STUDENTS MAY MODIFY CODE BELOW
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

        nop
        addi $15, $0, -10


# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# STUDENTS MAY MODIFY CODE ABOVE


exit:
        add $2, $0, 10
        syscall
                

.data

testcase1:
        .word   0x00200020    # odd parity is 1

testcase2:
        .word   0x00300020    # odd parity is 0
        
testcase3:
        .word  0x1234fedc     # odd parity is 0

Solutions

Expert Solution

Greetings!!

Code:

.data
prompt: .asciiz "Enter a number for calculating odd parity"
out: .asciiz "Odd parity is: "
.text
#display prompt message
la $a0,prompt       #loading the address of the prompt message
li $v0,4       #parameter for displaying prompt
syscall           #displaying
#read the upper limit
li $v0,5       #parameter for reading number
syscall           #read
move $t0,$v0       #save the number into t0
addi $t1,$t1,0       #initialize 0
addi $t7,$t7,0       #initialize 0
#processing..
loop:
beq $t1,32,end       #repeat for 32 times
addi $t1,$t1,1       #increment loop count
andi $t2,$t0,0x80000000   #logical and the msb of the number with 0x80000000
beq $t2,$0,skip       #check whether the result of the and is 0 or 1
addi $t3,$t3,1       #if the result is 1,then increment the count for 1
skip:
sll $t0,$t0,1       #shift the number left by 1 bit
j loop           #repeat
end:
andi $t4,$t3,0x00000001   #checking whether the number of 1s are even or odd
beq $t4,$0,jump       #if the number is even,skip the next line,parity is already set to 0
addi $t7,$t7,1       #if the number is odd,load parity as 1
jump:
#display the out message
la $a0,out       #loading the address of the out message
li $v0,4       #parameter for displaying out
syscall           #displaying
#display the count
add $a0,$0,$t7       #load the number of 1s count in register a0 for display
li $v0,1       #parameter for display the integer result
syscall           #display
#standard termination
li $v0,10       #parameter for standard termination
syscall

Program logic: Number of 1s are counted in the given number by shifting it left and then finally check whether the count is even or odd. If the count is even, print odd parity as 0 and otherwise 1.

Output screenshots:

Please note that the inputs are read in decimal format only.

Hope this helps


Related Solutions

write a verilog code to implement a digital system that has an odd counter that counts...
write a verilog code to implement a digital system that has an odd counter that counts from 1 to 11. Also, this system has an output Y that detects a specific number in the odd counter. Test your code when you detect the number 3, the output Y is 1, if the counter value is set to 3, otherwise 0.
Develop a communication plan for an airport security project. The project entails installing the hardware and software system that
From: Project management,Larson, E. W., & Gray, C. F. (2018). Project Management: The Managerial Process, 7thEdition. McGraw Hill.Develop a communication plan for an airport security project. The project entails installing the hardware and software system that (1) scans a passenger’s eyes, (2) fingerprints the passenger, and (3) transmits the information to a central location for evaluation.
How has Digital Media influenced (or changed) interpersonal communication? Include a historical (before and after the...
How has Digital Media influenced (or changed) interpersonal communication? Include a historical (before and after the digital media) and global perspective (include discussion of the US and at least two additional countries). Include whether the change has been positive, negative, or both.
13. Sales promotions include promotions that are part of the other components of the communication mix...
13. Sales promotions include promotions that are part of the other components of the communication mix TRUE FALSE
Include written explanation and picture diagram. Communication satellites are often placed in geosynchronous orbits, which means...
Include written explanation and picture diagram. Communication satellites are often placed in geosynchronous orbits, which means that the satellite always appears in the same location relative to a receiver on the ground. This requires among other things that the rotational speed at which the satellite orbits the planet is the same as the rotational speed at which the planet spins on its axis. Consider a planet with mass = 4.32 × 1024 kg and radius = 5.43 × 106 m...
Parent–child relationships may include communication that “shoots the other person down,” which often adds fuel to...
Parent–child relationships may include communication that “shoots the other person down,” which often adds fuel to negative situations. Assess the effect of harsh communication patterns between parents and children, and generate alternative patterns of communication. For each statement, generate a healthier alternative statement. I don’t understand why you do these things. How could someone with your brains and your background do such a thing? I do not understand how one little _____ is going to hurt you. You never tell...
Q1: Health communication environment include different approaches in your opinion what is the most important part...
Q1: Health communication environment include different approaches in your opinion what is the most important part and why ? Q2: New media theory is affected health communication, Explain it briefly? please DON'T put the answer in pic .
Assembly language: please comment on every line of code explaining each part. include head comments describing...
Assembly language: please comment on every line of code explaining each part. include head comments describing what your program does. Assignment 3A - A program that adds and subtracts 32-bit numbers After installing the assembler on the computer, enter the following program, save it, assemble it and run it. Do not forget to add a comment with your name in it. You will hand in a listing (e.g., addsum.asm) that should include your name ________________________________________ TITLE Add and Subtract (AddSum.asm)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT