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; ---------------------------------------------------------------------- |...
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.
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.
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 computer arithmetic distinct from pencil-and-paper forms?
How is computer arithmetic distinct from pencil-and-paper forms?
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]
Consider a system which has to accept prefix arithmetic expressions consisting of ‘+’(binary addition) , ‘-‘(binary...
Consider a system which has to accept prefix arithmetic expressions consisting of ‘+’(binary addition) , ‘-‘(binary subtraction), ‘*’(multiplication), ‘~’(unary subtraction), single digit numbers and compute their value. Examples: +12 → 3 ++12 → fail +*123 → 5 *+123 → 9 +123 → fail What parts would be required for such a system? How do these parts relate to the concepts studied? Could you write a program to implement such a system? (Layout of the structure and the logic of the...
What is the computer system in which admission, discharge, and transfer system are included? A. Clinical...
What is the computer system in which admission, discharge, and transfer system are included? A. Clinical Systems B. Patient Administration System C. Patients' Master Index D. Clinical coding and disease
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT