Hamza Code
Hamza Code
endmodule
initial
begin
Instr_Mem[0] = 8'b10010011;
Instr_Mem[1] = 8'b00001000;
Instr_Mem[2] = 8'b00010000;
Instr_Mem[3] = 8'b00010001;
Instr_Mem[4] = 8'b10010011;
Instr_Mem[5] = 8'b00000000;
Instr_Mem[6] = 8'b00000000;
Instr_Mem[7] = 8'b00010010;
// addi x3, x0, 0
Instr_Mem[8] = 8'b10010011;
Instr_Mem[9] = 8'b00000000;
Instr_Mem[10] = 8'b00000000;
Instr_Mem[11] = 8'b00011000;
Instr_Mem[12] = 8'b10010011;
Instr_Mem[13] = 8'b00000000;
Instr_Mem[14] = 8'b00000100;
Instr_Mem[15] = 8'b00100000;
// lw x5, 0(x1)
Instr_Mem[16] = 8'b00000011;
Instr_Mem[17] = 8'b00001000;
Instr_Mem[18] = 8'b00000000;
Instr_Mem[19] = 8'b00110001;
Instr_Mem[20] = 8'b00110011;
Instr_Mem[21] = 8'b00000001;
Instr_Mem[22] = 8'b00111000;
Instr_Mem[23] = 8'b00010110;
Instr_Mem[24] = 8'b10010011;
Instr_Mem[25] = 8'b00000100;
Instr_Mem[26] = 8'b00000100;
Instr_Mem[27] = 8'b00110001;
Instr_Mem[29] = 8'b11111111;
Instr_Mem[30] = 8'b11111111;
Instr_Mem[31] = 8'b00010010;
Instr_Mem[32] = 8'b01100011;
Instr_Mem[33] = 8'b00000001;
Instr_Mem[34] = 8'b00000000;
Instr_Mem[35] = 8'b00110010;
Instr_Mem[36] = 8'b11011111;
Instr_Mem[37] = 8'b11111110;
Instr_Mem[38] = 8'b11111111;
Instr_Mem[39] = 8'b11111110;
Instr_Mem[40] = 8'b10010011;
Instr_Mem[41] = 8'b00001000;
Instr_Mem[42] = 8'b00010001;
Instr_Mem[43] = 8'b00110001;
// sw x3, 0(x6)
Instr_Mem[44] = 8'b00100011;
Instr_Mem[45] = 8'b00000000;
Instr_Mem[46] = 8'b00011000;
Instr_Mem[47] = 8'b00110110;
Instr_Mem[48] = 8'b11011111;
Instr_Mem[49] = 8'b00000000;
Instr_Mem[50] = 8'b00000000;
Instr_Mem[51] = 8'b00000000;
end
always@(Instr_addr)
begin
end
endmodule
module mux_2_to_1(output [31:0] OUT, input [31:0] val_1, input [31:0] val_2, input select);
endmodule
module PC(output reg [31:0] PC_curr, input [31:0] PC_new, input CLK);
initial
begin
end
always@(posedge CLK)
begin
end
endmodule
`timescale 1ns / 1ps
module Adder(output [31:0] PC_next_target, input [31:0] PC_curr, input [31:0] offset);
endmodule
module RegFile(output wire [31:0] rs1_data, output wire [31:0] rs2_data, input CLK,
input [31:0] rd_data, input [4:0] rs1, input [4:0] rs2, input [4:0] rd, input RegWrite);
integer i;
initial
begin
Regfile[i] = 0;
end
always@(posedge CLK)
if(RegWrite)
begin
end
else
begin
end
endmodule
always@(opcode)
begin
case(opcode)
7'b0000011 : {regwrite, jump, ALUop, immsrc, ALUsrc, branch, datawrite, resultsrc} = {1'b1,
1'b0, 2'b00, 2'b00, 1'b1, 1'b0, 1'b0, 2'b01};
7'b0010011 : {regwrite, jump, ALUop, immsrc, ALUsrc, branch, datawrite, resultsrc} = {1'b1,
1'b0, 2'b10, 2'b00, 1'b1, 1'b0, 1'b0, 2'b00};
7'b1100011 : {regwrite, jump, ALUop, immsrc, ALUsrc, branch, datawrite, resultsrc} = {1'b0,
1'b0, 2'b01, 2'b10, 1'b0, 1'b1, 1'b0, 2'bxx};
7'b0110011 : {regwrite, jump, ALUop, immsrc, ALUsrc, branch, datawrite, resultsrc} = {1'b1,
1'b0, 2'b10, 2'bxx, 1'b0, 1'b0, 1'b0, 2'b00};
7'b1101111 : {regwrite, jump, ALUop, immsrc, ALUsrc, branch, datawrite, resultsrc} = {1'b1,
1'b1, 2'bxx, 2'b11, 1'bx, 1'b0, 1'b0, 2'b10};
7'b0100011 : {regwrite, jump, ALUop, immsrc, ALUsrc, branch, datawrite, resultsrc} = {1'b0,
1'b0, 2'b00, 2'b01, 1'b1, 1'b0, 1'b1, 2'bxx};
endcase
end
endmodule
module Imm_Extender(output reg [31:0] Imm_out, input [31:0] instruction, input [1:0] ImSrc);
always@(ImSrc or instruction)
begin
case(ImSrc)
endcase
end
endmodule
module ALU(output reg [31:0] ALUResult, output reg Zero, input ALUControl,
always@(ALUControl)
begin
case(ALUControl)
endcase
end
always@(ALUResult)
begin
if(ALUResult)
begin
else
begin
end
end
endmodule
endmodule
always@(*)
begin
case(ALU_op)
endcase
end
endmodule
module Data_Mem (output [31:0] data_out, input [31:0] data_in, input [31:0] address, input
DataWrite, input CLK);
initial
begin
DataMem[i] = 0;
end
always@(posedge CLK)
begin
if(DataWrite)
begin
end
end
endmodule
module mux_4_to_1(output [31:0] OUT, input [31:0] val_1, input [31:0] val_2, input [31:0] val_3,
input [1:0] select);
endmodule