Question

In: Electrical Engineering

I am trying to write the code for an 8 bit adder in VHDL so that...

I am trying to write the code for an 8 bit adder in VHDL so that I can program it onto my Elbert V2 Spartan 3A FPGA Development Board, but I keep getting errors. Any ideas what I am doing wrong?

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity adder8bit is
Port ( a : in STD_LOGIC_VECTOR(7 downto 0);
b : in STD_LOGIC_VECTOR(7 downto 0);
cin : in STD_LOGIC;
o : out STD_LOGIC_VECTOR(7 downto 0);
cout : out STD_LOGIC);
end adder8bit;

architecture Behavioral of adder8bit is

component fulladder is
   Port ( a : in STD_LOGIC;
b : in STD_LOGIC;
cin : in STD_LOGIC;
o : out STD_LOGIC;
cout : out STD_LOGIC
);
end component;

signal c : STD_LOGIC_VECTOR(6 downto 0);

begin

PROCESS (a,b,cin)
BEGIN

o(0) <= a(0) xor b(0) xor cin;
c(0) <= (cin and b(0)) or (cin and a(0)) or (a(0) and b(0));

for i in 1 to 7 loop

o(i) <= a(i) xor b(i) xor c(i-1);
c(i) <= (c(i-1) and b(i)) or (c(i-1) and a(i)) or (a(i) and b(i));

end loop;

cout <= c(6);

END PROCESS;

end Behavioral;

Solutions

Expert Solution

the corrected code is:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity adder8bit is
Port (    a : in STD_LOGIC_VECTOR(7 downto 0);
           b : in STD_LOGIC_VECTOR(7 downto 0);
           cin : in STD_LOGIC;
           o : out STD_LOGIC_VECTOR(7 downto 0);
           cout : out STD_LOGIC);
end adder8bit;

architecture Behavioral of adder8bit is

signal c : STD_LOGIC_VECTOR(8 downto 0);

begin

PROCESS (a,b,cin,c)
BEGIN

c(0)<=cin;
for i in 0 to 7 loop

o(i) <= a(i) xor b(i) xor c(i);
c(i+1) <= (c(i) and b(i)) or (c(i) and a(i)) or (a(i) and b(i));

end loop;

cout <= c(8);

END PROCESS;

end Behavioral;

Note:

1. Here, you are not using structural model, hence no need to take the component instanstiation.

2. In order to properly execute the program remove the lines

o(0) <= a(0) xor b(0) xor cin;
c(0) <= (cin and b(0)) or (cin and a(0)) or (a(0) and b(0));

add them also in for loop as i did. assign C(0) intially to cin. and take c as 9 bit data.

3. Assign c(8) to cout.

4. another important point inclue signal c in the process.


Related Solutions

Using the following VHDL code for an 8 bit adder, make the sum be displayed on...
Using the following VHDL code for an 8 bit adder, make the sum be displayed on the seven segment display of an Elbert V2 Spartan 3A FPGA Board. VHDL: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity state_bit_adder is Port ( clk : in STD_LOGIC; reset : in STD_LOGIC;            D : in STD_LOGIC;            Enable : out STD_LOGIC_vector (2 downto 0);            input: in std_logic_vector(7 downto 0);            SUM: out...
4. Use generate statement to write VHDL code for a 16 bit adder assuming the only...
4. Use generate statement to write VHDL code for a 16 bit adder assuming the only available building block is a full adder. Thank
Write a VHDL code to implement a Finite State Machine that with an 8 bit sequence...
Write a VHDL code to implement a Finite State Machine that with an 8 bit sequence input (can be any sequence, but lets say it is 11001000), determine how many states there are as well; so if the input sequence is correct it will show the number 1 in a 7 segment display, otherwise it will be 0 in the same 7 segment display. If the input sequence is incorrect, start from the beginning.
I am trying to create an 8-bit random number generator in verilog code using a mux,...
I am trying to create an 8-bit random number generator in verilog code using a mux, a d flip flop and a LFSR not sure what I am doing wrong but need some help with getting it working properly any help would be greatly appreciated. here is what I have so far: module RNG #(parameter size=8)(output [7:0]SO,output [7:0] RN,input clk,rst,input[size-1:0]seed,input L);    wire [7:0] Sin=SO[7]^SO[5]^SO[4]^SO[3];    ffw F1 (SO,clk,rst,Sin);    MUX M1 (Sin,seed,{SO[size-2:0],next},L);    xor X1 (next,SO[6],SO[7]);    assign RN=next;...
Design an 8-bit adder. Show Verilog code and testbench.
Design an 8-bit adder. Show Verilog code and testbench.
Write a VHDL code for a 8x8 bit multiplier. use structural approach. write the design code...
Write a VHDL code for a 8x8 bit multiplier. use structural approach. write the design code and testbench. Use for-generate if possible
I want VHDL program and testbench program for 4 bit binary full adder with fast carry...
I want VHDL program and testbench program for 4 bit binary full adder with fast carry using behavioral and structural style modling (ls7483)
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using...
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using full adder that is coded using data flow model. Use test bench to test 8-bit adder and consider at least five different test vectors to test it.
Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code...
Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code of 4-bit modulo-9 counter in ModelSim, and capture the screenshot of your simulated waveform. Assume clock period Tclk=100ns, initially, the counter is reset to Q3Q2Q1Q0=0000 you need to simulate a complete counting cycle plus one more additional clock period after it is reset to “0000” state.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT