Professional Documents
Culture Documents
BRANCH: -CSE
ROLLNO: -2021A1R084
ASSIGNMENT NO: -1
Q1: Construct a bus system with multiplexers for 6 registers. Write a code
using C language to show their hardware implementation.
Sol.
#include <stdio.h>
#define REG_NUM 6
int main() {
int regs[REG_NUM]; // array to hold register values
int bus; // value on the common bus
int mux_sel; // multiplexer selection input
// initialize register values
for (int i = 0; i< REG_NUM; i++) {
printf("Enter the integer to be stord on %d multiplexer: ", i+1);
scanf("%d",®s[i]);
}
// main loop
while (1) {
// read multiplexer selection input
printf("Enter the multiplexer selection input (0-5): ");
scanf("%d", &mux_sel);
// read value from the selected register
if( mux_sel> 5 || mux_sel< 0){
printf("Out of range!!!!!!!!");
break;
}
else{
bus = regs[mux_sel];
}
// output value on the common bus
printf("Value on the common bus: %d\n", bus);
}
return 0;
}
Q2: Implement the Circular Shift Microoperation using C++.
Sol. #include <iostream>
#include <bitset>
using namespace std;
int main() {
// Test circular shift left
int B1,S1;
cout<<"Enter the decimal number: ";
cin>>B1;
cout<<"How many bits you want to shift: ";
cin>>S1;
bitset<8> input1(B1);
bitset<8> output1 = circularShiftLeft(input1, S1);
cout<< "Circular shift left of " << input1 << " by " <<S1<<" bits are:
"<<output1 <<endl;
// Test circular shift right
bitset<8> input2(B1);
bitset<8> output2 = circularShiftRight(input2, S1);
cout<< "Circular shift right of " << input2 << " by " <<S1<<" bits are:
"<<output2 <<endl;
return 0;
}
Sol.The memory unit has 256 thousand words of 32 bits. This means that the
totalmemory size is:
256 thousand words x 32 bits/word = 8,388,608 bits
The instruction is stored in one word of memory and has four parts: an
indirect bit, an opcode, a register code part to specify one of the 64 registers,
and an address part.
Opcode: Complete instruction size - (indirect bit size + register code size +
address part size).
=> 32 - (1 + 6 + 18) = 7 bits are used to determine the opcode.
Indirect Bit(1-bit)
Operation code (7-bits)
Register code(6-bits)
Address Part(18-bits)
The number of bits in the data and address inputs of the memory is the same
as the word size of the memory unit, which in this case is 32 bits.