Question

Do Simulate a 4bit Ripple Carry adder in Simulink and generate the VHDL code to be implemented on DE2 board. Submit the VHDL

0 0
Add a comment Improve this question Transcribed image text
Answer #1


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity rc_adder is
port( a : in std_logic_vector(3 downto 0);  
b :   in std_logic_vector(3 downto 0);  
s : out std_logic_vector(3 downto 0);   -- 4 bit sum
   c :  out std_logic   -- carry out.
);
end rc_adder;

architecture Behavioral of rc_adder is


signal c0,c1,c2,c3 : std_logic := '0';
begin  

--first full adder
s(0) <= a(0) xor b(0);  --sum calculation
c0 <= a(0) and b(0);   --carry calculation
--second full adder
s(1) <= a(1) xor b(1) xor c0;
c1 <= (a(1) and b(1)) or (a(1) and c0) or (b(1) and c0);
--third full adder
s(2) <= a(2) xor b(2) xor c1;
c2 <= (a(2) and b(2)) or (a(2) and c1) or (b(2) and c1);
--fourth(final) full adder
s(3) <= a(3) xor b(3) xor c2;
c3 <= (a(3) and b(3)) or (a(3) and c2) or (b(3) and c2);
--final carry assignment
c <= c3;
end Behavioral;

The test bench program used for testing the design is given below:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

--this is how entity for your test bench code has to be declared.
entity testbench is
end testbench;

architecture behavior of testbench is

signal a, b , s : std_logic_vector(3 downto 0) :=(others => '0');
signal c :  std_logic:='0';

begin
UUT : entity work.rc_adder port map(a ,b ,s ,c );
--definition of simulation process
tb : process
begin
a<="0010";  
b<="1001";  
wait for 2 ns;

a<="1010";  
b<="0011";
wait for 2 ns;

a<="1000";  
b<="0101";  
wait for 2 ns;

a<="1010";  
b<="0110";  

wait;
end process tb;

end;

#RCA_waveform:

At the time of modifying code,we  assign a,b,s,c as num1,num2,sum,carry respectively.

here in wave form, a =>num1; b=>num2; s=>sum; c=> carry.

Current Simulation Time: 1000 ns pns 1 ns 2 ns 3 ns 4 ns 5 ns 6 ns 7 ns 8 ns 9 ns 10 ns 10 8 10 10 6 8 9 3 5 num1[3:0] num2(3

Add a comment
Know the answer?
Add Answer to:
Do Simulate a 4bit Ripple Carry adder in Simulink and generate the VHDL code to be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Find the propagation delays for a 20 bit ripple carry adder Given the following propagation delays...

    Find the propagation delays for a 20 bit ripple carry adder Given the following propagation delays Component AND Propagation Delay 9 OR 8 XOR 7 And that each full adder is implemented as A x1 A BlX1 B Cin Sum Cinx1(cin Cin x1 Cout Hint Draw out at least a 4-bit ripple carry adder before trying to answer this question.

  • Problem 2. Ripple Carry and Carry Look-ahead Adders For the binary adding circuit that adds n-bit...

    Problem 2. Ripple Carry and Carry Look-ahead Adders For the binary adding circuit that adds n-bit inputs x and y, the following equation gives ci+1 (the carry out bit from the i" position) in terms of the inputs for the ih bit sum x, yi, and ci (the carry-in bit): Letting gi xiyi and pi = xi+yi, this can be expressed as: ci+1 = gi+piCi a) In a ripple carry adder structure, the carry bits are computed sequentially. That is,...

  • 3. Digital circuits question. The figure below shows a 16-b carry-skip adder. It is composed of...

    3. Digital circuits question. The figure below shows a 16-b carry-skip adder. It is composed of 4 4-bit ripple carry adders and some extra logic to route the carry. Each 4bit ripple carry adder generates a group propagate signal. This is used to determine when the carry-in is going to be propagated all the way to the carry-out. When this is the case, addition is sped up by allowing the carry-in to skip the block and become the carry-in of...

  • 8.32 Using the ripple carry 4-bit parallel adder (A + B) circuit in Fig. 8.12, answer the followi...

    show all works and explain. 8.32 Using the ripple carry 4-bit parallel adder (A + B) circuit in Fig. 8.12, answer the following question. i XxAX,o. use the 4-bit adder module above to draw a moxlule that computes -4X using an 8-bit word in 2 s complement format. B b3babibo Cin co s3 s2 sl Fig. 8.12 Ripple carry adder for exercise 8.32 8.32 Using the ripple carry 4-bit parallel adder (A + B) circuit in Fig. 8.12, answer the...

  • Construct the 8-bit ripple-carry adder/subtractor for signed integers. Negative numbers are in th...

    Construct the 8-bit ripple-carry adder/subtractor for signed integers. Negative numbers are in the 2's complement form. The circuit has inputs X(7:0), Y(7:0), CO, M and outputs S(7:0), carry-out of MSB C8, OFL (OFL 1 when it occurs). The circuit should perform addition and subtraction of 8-bit signed numbers 2. with M-1 and M-0, respectively. a) Obtain the schematic for the 8-bit adder/subtractor with two 4-bit adder/subtractors from problem 1 as building blocks. X, Y, A, B, S can be shown...

  • b. Suppose you are provided with a 4-bit ripple carry adder. It has the following entity...

    b. Suppose you are provided with a 4-bit ripple carry adder. It has the following entity declaration and schematic representation А(3:0] B[3: entity fourbit FA is portA, B in std logic_vector (3 downto 0); 4-bit RCA Cin in std_logic; S out stdlogic_vector (3 downto 0) Cout out std logic: Cin Cout S3:0] end fourbitFA Create a VHDL architecture for the following circuit (15 Marks) C3:0] D[3:0] A[3:0] B[3:0] Е[3:0] F[3:0] 4-bit RCA 4-bit RCA inA 4-bit RCA CinB CinC Coutl...

  • Given: A 4-bit adder is implemented in a carry ripple style as shown in the figure...

    Given: A 4-bit adder is implemented in a carry ripple style as shown in the figure below. B3 A3 B2 A2 B1 A1 во АО FA c1 FA FA FA CO='1' SO Sought: Please calculate the output carries for each full adder (FA) using A= 0x04and B=0x04. It is required to show ALL incremental steps of the solution, then record each the final results in the table below. C4 C3 C2 ci

  • Introduction: This experiment studies the design of an 8-bit adder/subtractor circuit using VHDL capture. The experiment...

    Introduction: This experiment studies the design of an 8-bit adder/subtractor circuit using VHDL capture. The experiment investigates the implementation of addition and subtraction operations with circuits. This lab uses the virtual simulation environment to validate the design practically in the FPGA board. Equipment: • This experiment requires Quartus Prime and the Intel's DE2-115 FPGA board. • All students should have the Intel QP and ModelSim-Intel-Starter-Edition softwares installed in personal computers. • VPN connection to UNB Network and remote desktop software...

  • Question: Part 1: In the second part of this lab, we will extend our adder to...

    Question: Part 1: In the second part of this lab, we will extend our adder to also allow for subtraction of the second number from the first. To implement this, we must take the 2's compliment of the second number and add it to the first. This can be implemented using the circuit shown in Section 4.4.2 of the notes, which is shown again here in Figure 2. B3 A3 B2 A B, A, B, A, -SM 0: Add 1:...

  • Please code the following in Verilog: Write the HDL gate-level hierarchical description of a four-bit adder-subtractor...

    Please code the following in Verilog: Write the HDL gate-level hierarchical description of a four-bit adder-subtractor for unsigned binary numbers similar to the following circuit. You can instantiate the four-bit full adder described in the following example code Figure 4.13a, 4-Bit adder-subtractor without overflow Inputs: 4-Bit A, 4-Bit B, and Mode M (0-add/1-subtract) Interfaces: Carry Bits C1, C2, C3 Outputs: Carry C (1 Bit, C4), Sum S (4 bit) Bo A FA FA FA FA module Add half (input a,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT