Академический Документы
Профессиональный Документы
Культура Документы
1. Problem Statement
2. Design
3. Program
4. Results
1. Problem Statement
Design a serial Adder/subtarcter with accumulator for 8-bit binary numbers and implement
it using VHDL. Use 2s Complement to represent negative numbers. Draw state diagram
of control unit and implement it using VHDL. Report numbers of LUTs and CLBs used and
maximum frequency of operation after synthesis it for SPARTAN-3E device.
Submission Constraints:
Draw RTL for data-path and state diagram for control path
Use behavioral model to describe control unit and structural model for data-path design
Submit simulation and post synthesis obtained for at least four cased
i. Both positive numbers
ii. Both negative numbers
iii. One positive and other negative number (Larger than positive no.)
iv. One positive and other negative number (Smaller than positive no.)
Project must be design for the Spartan 3E, family XC3S100E kit with speed -5.
Report numbers of LUTs and CLBs used and maximum frequency of operation
after synthesis.
CODE must be synthesizable.
2. Design
input when the 'rst' is made high, otherwise, they shift the input serially for each clock.
The accumulator has been implemented as a shift register with parallel output capability.
Whenever 'stop' is made high, the contents of the shift register are latched on the output.
Whenever the control unit receives the 'start' signal or after the completion of
one addition, it clears the flip flop, and accepts the inputs. On completion of
addition, it provides appropriate signals to latch the output.
The carry of present addition has been stored in a D flip-flop for its use as carry
in of next addition.
CONTROL
RST
IN1
SUM
0
7
R
S
T
A
FULL ADDER
B
Cout
R
S
T
Cin
S
T
A
R
T
S
T
O
P
7
IN2
Q
C
L
K
CLK
OUT1
3. PROGRAM
--MAIN PROGRAM
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use
IEEE.STD_LOGIC_ARITH.ALL; use
IEEE.STD_LOGIC_UNSIGNED.ALL;
entity serial_adder is
Port ( in1 : in STD_LOGIC_VECTOR (7 downto 0);
in2 : in STD_LOGIC_VECTOR (7 downto 0);
out1 : out STD_LOGIC_VECTOR (7 downto 0);
clk : in STD_LOGIC;
start : in STD_LOGIC);
end serial_adder;
architecture Behavioral of serial_adder
is signal s0,s1,s2,s3,s4,s5,s6:STD_LOGIC;
component shift
Port ( in1 : in STD_LOGIC_VECTOR (7 downto 0);
clk : in STD_LOGIC;
rst: in std_logic;
out1 : out STD_LOGIC);
end component;
component control_fsm
Port ( clk : in STD_LOGIC;
start : in STD_LOGIC;
rst : out STD_LOGIC;
stop : out STD_LOGIC);
end component;
component d_ff
Port ( d : in STD_LOGIC;
clk : in STD_LOGIC;
rst : in STD_LOGIC;
q : out STD_LOGIC);
end component;
component full_adder
Port ( in1 : in STD_LOGIC;
in2 : in STD_LOGIC;
cin : in STD_LOGIC;
sum : out STD_LOGIC;
cout : out STD_LOGIC);
end component;
component accumulator
Port ( in1 : in STD_LOGIC;
clk : in STD_LOGIC;
stop:in STD_LOGIC;
out1 : out STD_LOGIC_VECTOR (7 downto 0));
end component;
begin
U1: control_fsm port map(clk,start,s0,s1);
U2: shift port map(in1,clk,s0,s2);
U3: shift port map(in2,clk,s0,s3);
U4: full_adder port map(s2,s3,s4,s5,s6);
U5: d_ff port map(s6,clk,s0,s4);
U6:accumulator port map(s5,clk,s1,out1);
end Behavioral;
--CONTROL FSM CODE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use
IEEE.STD_LOGIC_ARITH.ALL; use
IEEE.STD_LOGIC_UNSIGNED.ALL;
entity control_fsm is
Port ( clk : in STD_LOGIC;
start : in STD_LOGIC;
rst : out STD_LOGIC;
stop : out STD_LOGIC);
end control_fsm;
architecture Behavioral of control_fsm is
type fsm_state is (s0,s1,s2,s3,s4,s5,s6,s7,s8);
signal current_state: fsm_state;
begin
process(clk,start)
begin
if(start='1') then
current_state<=s0;
elsif (clk'event and clk='1') then
case current_state is
when s0 =>
rst<='1';
stop<='0';
current_state<=s1;
when s1 =>
rst<='0';
stop<='0';
current_state<=s2;
when s2 =>
rst<='0';
stop<='0';
current_state<=s3;
when s3 =>
rst<='0';
stop<='0';
current_state<=s4;
when s4 =>
rst<='0';
stop<='0';
current_state<=s5;
when s5 =>
rst<='0';
stop<='0';
current_state<=s6;
when s6 =>
rst<='0';
stop<='0';
current_state<=s7;
when s7 =>
rst<='0';
stop<='0';
current_state<=s8;
when s8 =>
rst<='0';
stop<='1';
current_state<=s0;
end case;
end if;
end process;
end Behavioral;
entity full_adder is
Port ( in1 : in STD_LOGIC; in2
: in STD_LOGIC; cin :
in STD_LOGIC; sum : out
STD_LOGIC; cout : out
STD_LOGIC);
end full_adder;
architecture Behavioral of full_adder is
begin
sum<=in1 xor in2 xor cin;
cout<=(in1 and in2) or (in1 and cin) or (in2 and
cin); end Behavioral;
end Behavioral;
end Behavioral;
--ACCUMULATOR CODE
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; use
IEEE.STD_LOGIC_ARITH.ALL; use
IEEE.STD_LOGIC_UNSIGNED.ALL;
entity accumulator is
Port ( in1 : in STD_LOGIC;
clk : in STD_LOGIC;
stop:in STD_LOGIC;
out1 : out STD_LOGIC_VECTOR (7 downto 0));
end accumulator;
architecture Behavioral of accumulator is
begin
process(clk,stop)
4. RESULTS
Various test cases have been provided for
verification. 1. 44 (2Ch) +45(2Dh) = 89(59h)
2.-19(EDh) + -7(F9h) = -26(E6h)
3. -75(B5h) + 59(3Bh)= -16(F0h)
4. -39(D9h) + 92(5Ch)= 53 (35h)
SYNTHESIS REPORT
Slices
Slice Flip Flops
4 input LUTs
Maximum Frequency
Device
24
42
41
426.26 MHz
Sparta 3E