Lab 1 Report
Lab 1 Report
PART 1
a. Hardware modelling using VHDL code
b. Synthesize result
==============================================================
*
Advanced HDL Synthesis Report
*
==============================================================
Macro Statistics
# Registers
: 8
Flip-Flops
: 8
# Xors
: 2
1-bit xor2
: 2
==============================================================
*
Final Report
*
==============================================================
Final Results
RTL Top Level Output File Name
: Part1.ngr
Top Level Output File Name
: Part1
Output Format
: NGC
Optimization Goal
: Speed
Keep Hierarchy
: No
Design Statistics
# IOs
: 10
Cell Usage :
# BELS
: 2
#
LUT2
: 2
# FlipFlops/Latches
: 8
#
FDC
: 7
#
FDP
: 1
# Clock Buffers
: 1
#
BUFGP
: 1
# IO Buffers
: 9
#
IBUF
: 1
#
OBUF
: 8
==============================================================
Comments: The synthesized result contains 8 flip-flops and 2 LUT (2 xor gates) which are
the same as the given circuit.
c. Simulating result
Explaination: Flip-flops are triggered by the edge of the clock. Possitive edge flip-flops sample
the input only at the possive edges of the clock. There are 2 possitve states in this case
(temp_x(n) can only take 0 or 1), the initial value for temp_x is 00000000 as required.
Transition between these states have to occur at the possitive edge of the clock.
Testbench code is shown below:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity Part1testbench is
end Part1testbench;
architecture behavioral of Part1testbench is
component Part1
port ( x : out STD_LOGIC_VECTOR (0 to 7);
reset : in STD_LOGIC;
clock : in STD_LOGIC);
end component;
signal reset: STD_LOGIC := '0';
signal clock : STD_LOGIC := '0';
signal x : STD_LOGIC_VECTOR (0 to 7);
constant clock_period : time := 10 ns; --clock period
begin
uut: Part1 PORT MAP (x => x,
reset => reset,
clock => clock);
clock_process: process
begin
clock <= '0';
wait for clock_period/2;
clock <= '1';
wait for clock_period/2;
end process;
stim_proc: process
begin
wait for 100 ns; --initial result should be 00000000
reset <='1';
wait for 10 ns; -- first flip-flop, the result should be 00000010
reset <='0';
wait for 10 ns; -- the result should be 00000001
reset <= '1';
wait for 10 ns;-- the result should be 00000010 and so on.
reset <= '0';
wait;
end process;
end;
As we can see for the Figure 2, the value of x vector has been change at every clock edge. The
output is clearly the same as expected.
2. PART 2
a. Hardware modelling of 4-bit ALU
VHDL code for 4-bit ALU with given function is shown below
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
entity lab1alu is
Port ( M : in STD_LOGIC;
S : in STD_LOGIC_VECTOR(1
A : in STD_LOGIC_VECTOR(3
B : in STD_LOGIC_VECTOR(3
Co : in STD_LOGIC;
F : out STD_LOGIC_VECTOR(3
Cout : out STD_LOGIC;
Flag : out STD_LOGIC);
end lab1alu;
DOWNTO 0);
DOWNTO 0);
DOWNTO 0);
DOWNTO 0);