Assignment3 2021HT80531
Assignment3 2021HT80531
Assignment-3
PAVANSAI C
2021HT80531
Problem Statement:
STATEMENT: Given that the sequence of instructions to be executed by the processor is guaranteed to be free
from pipeline hazards, Design a 5 – stage (Instruction Fetch; Decode, Read operand; Execute; Write back)
pipelined RISC processor that can execute following register– to – register instructions with a throughput of
one instruction per clock cycle.
STEP 0: Draw the detailed architecture level diagram of the processor, naming and depicting the various
architectural blocks (e.g. register file, instruction memory, ALU, pipeline registers, PC and combinational
functional blocks etc).
STEP 1: Create Verilog/ VHDL behavioral models for each of the architectural blocks. (Register file, Instruction
memory, ALU, Pipeline registers, PC etc)
STEP 2: Build the top level structural model of the processor by instantiating and interconnecting the
architectural blocks created in step 1 and write test bench to verify the functionality.
Opcode
MUL 0 --------------- 001
SHIFT 0 --------------- 010
XOR 0 ------------------ 011
NOR 0 -------------- 100
The register file has 32 number of 32 bit registers. The data in registers is stored as unsigned integers. Assume
that register file has two 32-bit read ports: A and B for data reading and one 32 bit write port: C for data
writing. At the rising edge of the clock the read ports A and B output the data from the registers whose
addresses are present at port A address and port B address respectively if the enable read port A and enable
read port B signals are true. At the falling edge of a clock, data is written to the register whose address is
present at Port C address if write enable Port C is true. Design the pipeline registers such that they are latched
at the rising edge of the clock. Specify the size and format of all pipeline registers including the fields holding
the decoded control signals as well as data.
The instruction memory is of size 128 bytes. A read operation from the memory outputs 4 consecutive bytes of
information (starting from the byte address provided to the memory) at the positive edge of clock if the read
enable instruction memory signal is true. Byte addresses must be aligned and to be provided to memory must
be either 0 or multiples of 4.
Architecture Diagram
module program_counter (
input clk,
input reset,
);
if (reset)
else
end
endmodule
module instruction_mem (
input re,
);
};
if (reset) begin
end
end
endmodule
module decode (
);
if (reset) begin
end
end
endmodule
module register_file (
input we,
);
if (reset) begin
end
if (ra_en)
if (rb_en)
end
end
if (we)
registers[wc] <= wd;
end
endmodule
module alu (
input [31:0] a,
input [31:0] b,
);
input [31:0] a;
input [31:0] b;
begin
case (op)
4'h1: alu_op = a * b;
4'h3: alu_op = a ^ b;
endcase
end
endfunction
y = alu_op(a, b, op);
end
endmodule
module pipeline #(
parameter WIDTH = 32
input clk,
input reset,
);
if (reset)
else
end
endmodule
module risc_proc (
);
endmodule
Verilog Testbench Code:
module top_tb;
logic clk_ipt;
logic rst_ipt;
// DUT
risc_proc dut_instance (
.clk(clk_ipt),
.reset(rst_ipt),
.im_re(im_re_ipt),
.rf_ra_en(rf_rd_a_ipt),
.rf_rb_en(rf_rd_b_ipt),
.rf_we(rf_we_ipt),
.o_pc(opt_pc),
.o_im(opt_im),
.o_dec_reg1(o_dec_reg1),
.o_dec_reg2(o_dec_reg2),
.o_dec_reg3(o_dec_reg3),
.o_dec_op(o_dec_op),
.o_rf_r1(opt_rf_r1),
.o_rf_r2(opt_rf_r2),
.o_alu(opt_alu));
// Clock
initial
begin
clk_ipt = 1'b0;
end
initial
begin
$dumpfile("dump.vcd");
$dumpvars();
end
// Reset generator
initial begin
im_re_ipt =1;
rf_rd_a_ipt=1;
rf_rd_b_ipt=1;
rf_we_ipt=1;
#1000ns $finish;
end
// Monitor
case(opcode)
endcase
end
always @(negedge clk_ipt) begin
Test_Pass=0;
end
else begin
case(opcode)
endcase
end
end
final begin
if(Test_Pass == 1)
else
$display("TEST FAILED");
end
endmodule
Simulation Output:
Conclusion:
5 – stage (Instruction Fetch; Decode; Read operand; Execute; Write back)
pipelined RISC processor that can execute register– to – register instructions
with a throughput of one instruction per clock cycle is designed, simulated and
verified.