Question

In: Electrical Engineering

The heart of a computer system is an ARITHMETIC AND LOGIC UNIT (ALU) which is responsible...

The heart of a computer system is an ARITHMETIC AND LOGIC UNIT (ALU) which is responsible for executing arithmetic (e.g., addition, subtraction, etc.) and logic (e.g., AND, OR, etc.) operations. In this project, you will design, simulate, and implement a simple 1-bit ALU.

The truth table for ALU is given below:

Operation Selection Inputs Operation Output(s)
S0 S1 A B
0 0 A AND B AB
0 1 A NOR B (A+B)’
1 0 A XNOR B (A⊕B)’
1 1 A SUB B Borrow, Difference








Solutions

Expert Solution

Verilog code for the given design

// Code your design here

module ALU(A,B,s0,s1,Y,borrow_carry);

input A,B;

input s0,s1;

output reg Y;

output reg borrow_carry;

  

  

always @(*)

begin

case ({s1,s0})

00: begin Y= (A & B); borrow_carry = 1'b0;end

01: begin Y=(~(A | B)); borrow_carry = 1'b0;end

10: begin Y= (~(A ^ B)); borrow_carry = 1'b0; end

11: begin Y= (A ^ B); borrow_carry = ((~ A ) & B); end

default begin Y=1'b0; borrow_carry = 1'b0; end

endcase

end

endmodule

  

Test bench code

// Code your testbench here

// or browse Examples

module test;

reg A,B;

reg s0,s1;

wire Y;

wire borrow_carry;

  

ALU dut(A,B,s0,s1,Y,borrow_carry);

  

initial

begin

$dumpfile ("var.vcd");

$dumpvars ;

A=1'b1;B=1'b1;s1=1'b1;s0=1'b1;#10;

s1=1'b0;s0=1'b1;#10;

s1=1'b1;s0=1'b0;#10;

s1=1'b0;s0=1'b0;#10;

A=1'b1;B=1'b0;s1=1'b1;s0=1'b1;#10;

s1=1'b0;s0=1'b1;#10;

s1=1'b1;s0=1'b0;#10;

s1=1'b0;s0=1'b0;#10;

$finish;

end

endmodule

Simulation results


Related Solutions

write an Arithmetic Logic Unit (ALU) in verilog.
write an Arithmetic Logic Unit (ALU) in verilog.
Write the VERILOG code for an arithmetic/logic unit (ALU) with a test bench that does the...
Write the VERILOG code for an arithmetic/logic unit (ALU) with a test bench that does the following with 4 bit inputs , and can be tested in on nexys 4 board This is to be implement on : ISE Design Suite - Xilinx /* ALU Arithmetic and Logic Operations ---------------------------------------------------------------------- |ALU_Sel| ALU Operation ---------------------------------------------------------------------- | 0000 | ALU_Out = A + B; ---------------------------------------------------------------------- | 0001 | ALU_Out = A - B; ---------------------------------------------------------------------- | 0010 | ALU_Out = A * B;...
Write the VERILOG code for an arithmetic/logic unit (ALU) following , and can be tested in...
Write the VERILOG code for an arithmetic/logic unit (ALU) following , and can be tested in on nexys 4 board This is to be implement on : ISE Design Suite - Xilinx /* ALU Arithmetic and Logic Operations ---------------------------------------------------------------------- |ALU_Sel| ALU Operation ---------------------------------------------------------------------- | 0000 | ALU_Out = A + B; ---------------------------------------------------------------------- | 0001 | ALU_Out = A - B; ---------------------------------------------------------------------- | 0010 | ALU_Out = A * B; ---------------------------------------------------------------------- | 0011 | ALU_Out = A / B; ---------------------------------------------------------------------- |...
a. Design a binary-to-octal converter. b. Design a logic circuit by which the following arithmetic expression...
a. Design a binary-to-octal converter. b. Design a logic circuit by which the following arithmetic expression can be calculated and show how X = 9 - 5 c. Write a short note on the data distributor circuit.
Which group of pacemaker cells is responsible for setting the heart rate in a healthy patient?...
Which group of pacemaker cells is responsible for setting the heart rate in a healthy patient? Write a flow diagram (eg: structure A --> structure B --> structure C, etc.) to describe the path that an action potential would take as it makes its way through the electrical conduction system of the heart, being sure to name all structures. What structure enables action potentials to directly spread between neighbouring cardiomyocytes? Be specific.
Imagine you are responsible for the performance improvement of an old computer system. Your boss told...
Imagine you are responsible for the performance improvement of an old computer system. Your boss told you that since a large budget for the new fiscal year has been approved and covers expenses with hardware upgrade you can just create a cluster computer with a large number of parallel processing units managed by some cluster operating system line MS-Windows Server 2019. You will not be able to make any changes to the software. Please, provide your recommendations for your boss...
Q1 A- What is a register? How registers work together with ALU and Control Unit to...
Q1 A- What is a register? How registers work together with ALU and Control Unit to execute a program? What is the fetch-execute cycle? B- What is the difference to implement a control unit using microprogrammed or hardwired approaches? What is clock cycle? What are different addressing modes?
How is Logics such as (Predicate Logic, Propositional Logic, and Logical Reasoning) used in Computer Science?...
How is Logics such as (Predicate Logic, Propositional Logic, and Logical Reasoning) used in Computer Science? Examples of how it implies to computer science would be great.
draw state machine and write verilog code of an ALU unit that shifts left when the...
draw state machine and write verilog code of an ALU unit that shifts left when the control signal 'OP' is 00, shifts right when control is ''01'' and increments when control is ''10''. Fpr control ''11'' , it does nothing. inputs are Date [3:0] and clk, and the output is Out [3:0]
How is computer arithmetic distinct from pencil-and-paper forms?
How is computer arithmetic distinct from pencil-and-paper forms?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT