-
Notifications
You must be signed in to change notification settings - Fork 0
/
top_module.v
67 lines (60 loc) · 1.64 KB
/
top_module.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 03/04/2023 08:06:15 AM
// Design Name:
// Module Name: top_module
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module top_module(
input wire clk, n_reset // clock and reset inputs
);
localparam ADDRESS_WIDTH = 32,
INSTR_WIDTH = 32,
PROGRAM = "factorial.txt";
wire [31:0] read_data, write_data, alu_result, instr, pc;
mips mcu (
// input ports
.clk(clk),
.n_reset(n_reset),
.read_data(read_data),
.instr(instr),
// output ports
.mem_write(mem_write),
.write_data(write_data),
.alu_result(alu_result),
.pc(pc)
);
data_mem #(
.ADDRESS_WIDTH(32),
.DATA_WIDTH(32)
) dm (
.clk(clk),
.n_clr(1'b1),
.write_en(mem_write),
.data_in(write_data),
.addr(alu_result),
.data_out(read_data)
);
// Instantiate the instruction memory module
instr_mem #(
.ADDRESS_WIDTH(ADDRESS_WIDTH), // Set the address width to 32 bits
.INSTR_WIDTH(INSTR_WIDTH), // Set the instruction width to 32 bits
.PROGRAM(PROGRAM) // Set the program file to PROGRAM
) instruction_memory (
.addr(pc), // Address input wire
.instr(instr) // Fetched instruction output wire
);
endmodule