2022-08-14 23:05:44 +00:00
|
|
|
// Module Name: top_level
|
2022-08-14 01:06:19 +00:00
|
|
|
// Project Name: CSE141L
|
|
|
|
// Description: top level RTL for processor
|
|
|
|
|
|
|
|
import Definitions::*;
|
|
|
|
|
2022-08-13 22:34:01 +00:00
|
|
|
module top_level(
|
2022-08-14 01:06:19 +00:00
|
|
|
input clk, init, req,
|
|
|
|
output logic ack
|
|
|
|
);
|
|
|
|
|
|
|
|
parameter T=10;
|
|
|
|
parameter W=8;
|
|
|
|
|
|
|
|
logic [8:0] Instruction;
|
|
|
|
logic [W-1:0] ALU_Out;
|
|
|
|
logic [W-1:0] RegOutA, RegOutB; // select from register inputs or immediate inputs
|
2022-08-14 20:44:51 +00:00
|
|
|
logic [T-1:0] ProgCtr_p1;
|
2022-08-14 01:06:19 +00:00
|
|
|
logic [W-1:0] mem_out;
|
|
|
|
op_mne ALU_OP; // control ALU operation
|
|
|
|
logic [W-1:0] ALU_A, ALU_B;
|
|
|
|
logic RegWrite, Done_in;
|
2022-08-14 20:44:51 +00:00
|
|
|
logic [3:0] RaddrA, RaddrB, Waddr;
|
|
|
|
logic [W-1:0] RegInput;
|
2022-08-14 01:06:19 +00:00
|
|
|
logic BranchEZ, BranchNZ, BranchAlways;
|
|
|
|
logic write_mem;
|
|
|
|
logic Zero_in, Zero_out;
|
|
|
|
logic Done_out;
|
|
|
|
logic [T-1:0] ProgCtr;
|
|
|
|
|
2022-08-14 01:54:10 +00:00
|
|
|
Ctrl control (.*);
|
2022-08-14 01:06:19 +00:00
|
|
|
|
2022-08-14 01:54:10 +00:00
|
|
|
ALU alu (
|
2022-08-14 01:06:19 +00:00
|
|
|
.A(ALU_A),
|
|
|
|
.B(ALU_B),
|
|
|
|
.ALU_OP(ALU_OP),
|
|
|
|
.Out(ALU_Out),
|
|
|
|
.Zero(Zero_in)
|
|
|
|
);
|
|
|
|
|
2022-08-14 01:54:10 +00:00
|
|
|
InstFetch pc (
|
2022-08-14 01:06:19 +00:00
|
|
|
.Clk(clk),
|
|
|
|
.Reset(init),
|
|
|
|
.BranchEZ(BranchEZ),
|
|
|
|
.BranchNZ(BranchNZ),
|
|
|
|
.BranchAlways(BranchAlways),
|
|
|
|
.Zero(Zero_out),
|
|
|
|
.Done(Done_out),
|
|
|
|
.Target(ALU_A),
|
|
|
|
.ProgCtr(ProgCtr),
|
2022-08-14 20:44:51 +00:00
|
|
|
.ProgCtr_p1(ProgCtr_p1)
|
2022-08-14 01:06:19 +00:00
|
|
|
);
|
|
|
|
|
2022-08-14 01:54:10 +00:00
|
|
|
RegFile regfile (
|
2022-08-14 01:06:19 +00:00
|
|
|
.Clk(clk),
|
|
|
|
.Reset(init),
|
|
|
|
.WriteEn(RegWrite),
|
|
|
|
.RaddrA(RaddrA),
|
|
|
|
.RaddrB(RaddrB),
|
|
|
|
.Waddr(Waddr),
|
|
|
|
.DataIn(RegInput),
|
|
|
|
.start(req),
|
|
|
|
.DataOutA(RegOutA),
|
2022-08-26 04:02:47 +00:00
|
|
|
.DataOutB(RegOutB)
|
2022-08-14 01:06:19 +00:00
|
|
|
);
|
|
|
|
|
2022-08-14 20:44:51 +00:00
|
|
|
DataMem DM (
|
2022-08-14 01:06:19 +00:00
|
|
|
.Clk(clk),
|
|
|
|
.WriteEn(write_mem),
|
|
|
|
.DataAddress(ALU_Out),
|
|
|
|
.DataIn(RegOutB),
|
|
|
|
.DataOut(mem_out)
|
|
|
|
);
|
|
|
|
|
2022-08-14 01:54:10 +00:00
|
|
|
InstROM rom (
|
2022-08-14 01:06:19 +00:00
|
|
|
.InstAddress(ProgCtr),
|
|
|
|
.InstOut(Instruction)
|
|
|
|
);
|
|
|
|
|
2022-08-26 04:02:47 +00:00
|
|
|
Flags f (
|
|
|
|
.Clk(clk),
|
|
|
|
.Reset(init),
|
|
|
|
.WriteEn(RegWrite),
|
|
|
|
.start(req),
|
|
|
|
.Zero_in(Zero_in),
|
|
|
|
.Zero_out(Zero_out),
|
|
|
|
.Done_in(Done_in),
|
|
|
|
.Done_out(Done_out)
|
|
|
|
);
|
|
|
|
|
2022-08-14 01:06:19 +00:00
|
|
|
assign ack = Done_out;
|
2022-08-13 22:34:01 +00:00
|
|
|
|
|
|
|
endmodule
|
|
|
|
|