Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Create the VHDL files provided by in appendix A adding them to your VHDL project ( Remember you need only one project for

1. Create the VHDL files provided by in appendix A adding them to your VHDL
project (Remember you need only one project for the entire course).
2. Fully comment the code provided in appendices A and B.
3. Obtain the RTL schematics of the Instruction Fetch stage, and each of its
components. Write down the differences between these schematics and the ones
in Figure 1.
4. Translate the code shown in the listing 5.1 to binary using the basic instruction
formats shown in Figure 3 and fill the two leftmost columns of Table 1, with the
register letters u, v, w, x, y resolved to their equivalent numbers as explained
below.
Listing 5.1: Assembly Code
start: lw Ru,4(R0)
lw Rv,8(R0)
add Rw, Ru, Rv
sub Rx, Ru, Rv
sw Rx,12(R0)
slt Ry, Ru, Rv
beq Ru, Ru, start
where u is the first non-zero digit of your id number, v is the second nonzero digit of
your id number, w is the third nonzero digit of your id number, and x is the fourth non
zero digit of your id number, and y is a random number between 10 and 31.
5. Create a test bench file and run a simulation showing the operation of the instruction
fetch stage. You must first load your program (Listing 5.1) binary instructions obtained
in the previous step, into the instruction memory in order to have instructions to fetch.
To do that follow the sample test bench file shown in appendix B. Your simulation
should look similar to the one in Figure 4, only that it should include all instructions to
be loaded and fetched. Explain the results of that simulation using annotations on the
timing diagram. Figure 4: IF simulation timing diagram for 2 instructions. Source: Generated using Xilinx Vivado
Table 1: Instructions
Instructions loaded to IM Output Port Signals from Simulation
Assembly Hexadecimal Clock Cycle Instruction (hex) PC+4(hex)
Appendix: A: Code
Listing A.1: Instruction Fetch Stage Code
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity IFetch is
Port ( clock, Resetn, branch : in STD_LOGIC;
read, write : in STD_LOGIC;
PC_out, PCmas4 : out STD_LOGIC_VECTOR (31 downto 0);
data_input: in STD_LOGIC_VECTOR (31 downto 0);
branch_address : in STD_LOGIC_VECTOR (31 downto 0);
Instruction: out STD_LOGIC_VECTOR (31 downto 0));
end IFetch;
architecture Behavioral of IFetch is
signal PC_in, PC, PC_plus_4 : std_logic_vector(31 downto
0):=(others=>'0');
component mem_module is --For 2^N-1 words
generic(N: integer:=8);
Port ( clock: in std_logic;
address : in STD_LOGIC_VECTOR (N-1 downto 0);
data_input: in STD_LOGIC_VECTOR (31 downto 0);
data_output: out STD_LOGIC_VECTOR (31 downto 0);
Read, write: in STD_LOGIC);
end component;
component mux_2_1_32bits is
port(
input0 : in std_logic_vector(31 downto 0);
input1 : in std_logic_vector(31 downto 0);
output : out std_logic_vector(31 downto 0);
control : in std_logic);
end component;
component registron is
Generic (N: integer:=32);
Port ( clock, enable : in std_logic;
D : in STD_LOGIC_VECTOR (N-1 downto 0);
Q : out STD_LOGIC_VECTOR (N-1 downto 0);
Resetn : in STD_LOGIC);
end component;
begin
PC_out=PC;
Instruction_Memory: mem_module generic map(N=>8)
port map( clock,
PC(7 downto 0),
data_input,
Instruction,
read,
write);
PC_reg: registron generic map (N=>32)
port map( clock,
resetn,
PC_in,
PC,
resetn);
branch_mux : mux_2_1_32bits port map (PC_plus_4,
branch_address,
PC_in,
branch);
PC_plus_4=PC+4;
PCmas4=PC_plus_4;
end Behavioral;
Memory Module
Listing A.2: Memory Module Code
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity mem_module is
generic(N: integer:=8); --For 2^N-1 bits
Port (clock: in std_logic;
address : in STD_LOGIC_VECTOR (N-1 downto 0);
data_input: in STD_LOGIC_VECTOR (31 downto 0);
data_output: out STD_LOGIC_VECTOR (31 downto 0);
Read, write: in STD_LOGIC);
end mem_module;
architecture Behavioral of mem_module is
type mem is array (2**(N-2)-1 downto 0) of std_logic_vector(7
downto 0);
signal mem0 : mem:=(others=>(others=>'0'));
signal mem1 : mem:=(others=>(others=>'0'));
signal mem2 : mem:=(others=>(others=>'0'));
signal mem3 : mem:=(others=>(others=>'0'));
signal address_internal :integer range 0 to 2**(N-2)-1;
signal data_out_int :STD_LOGIC_VECTOR (31 downto 0);
begin
address_internal=conv_integer(address(N-1 downto 2));
data_output=data_out_int;
data_out_int = mem0(address_internal) &
mem1(address_in
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago