This repository has been archived on 2023-12-21. You can view files and clone it, but cannot push or open issues or pull requests.
cse141L-project/RTL/top_level.sv

88 lines
1.6 KiB
Systemverilog
Raw Normal View History

2022-08-14 01:06:19 +00:00
// Module Name: ALU
// 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
logic [T-1:0] ProgCtr_p4;
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;
logic [3:0] RaddrA, RaddrB, Waddr, RegInput;
logic BranchEZ, BranchNZ, BranchAlways;
logic write_mem;
logic Zero_in, Zero_out;
logic Done_out;
logic [T-1:0] ProgCtr;
Ctrl #() control (.*);
2022-08-14 01:06:19 +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)
);
InstFetch #() pc (
.Clk(clk),
.Reset(init),
.BranchEZ(BranchEZ),
.BranchNZ(BranchNZ),
.BranchAlways(BranchAlways),
.Zero(Zero_out),
.Done(Done_out),
.Target(ALU_A),
.ProgCtr(ProgCtr),
.ProgCtr_p4(ProgCtr_p4)
);
RegFile #() regfile (
2022-08-14 01:06:19 +00:00
.Clk(clk),
.Reset(init),
.WriteEn(RegWrite),
.RaddrA(RaddrA),
.RaddrB(RaddrB),
.Waddr(Waddr),
.DataIn(RegInput),
.Zero_in(Zero_in),
.Done_in(Done_in),
.start(req),
.DataOutA(RegOutA),
.DataOutB(RegOutB),
.Zero_out(Zero_out),
.Done_out(Done_out)
);
DataMem #() datamem (
2022-08-14 01:06:19 +00:00
.Clk(clk),
.Reset(init),
.WriteEn(write_mem),
.DataAddress(ALU_Out),
.DataIn(RegOutB),
.DataOut(mem_out)
);
InstROM #() rom (
2022-08-14 01:06:19 +00:00
.InstAddress(ProgCtr),
.InstOut(Instruction)
);
assign ack = Done_out;
2022-08-13 22:34:01 +00:00
endmodule