-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskeleton.v
105 lines (94 loc) · 4.07 KB
/
skeleton.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* NOTE: you should not need to change this file! This file will be swapped out for a grading
* "skeleton" for testing. We will also remove your imem and dmem file.
*
* NOTE: skeleton should be your top-level module!
*
* This skeleton file serves as a wrapper around the processor to provide certain control signals
* and interfaces to memory elements. This structure allows for easier testing, as it is easier to
* inspect which signals the processor tries to assert when.
*/
module skeleton(clock, reset, imem_clock, dmem_clock, processor_clock, regfile_clock);
input clock, reset;
/*
Create four clocks for each module from the original input "clock".
These four outputs will be used to run the clocked elements of your processor on the grading side.
You should output the clocks you have decided to use for the imem, dmem, regfile, and processor
(these may be inverted, divided, or unchanged from the original clock input). Your grade will be
based on proper functioning with this clock.
*/
output imem_clock, dmem_clock, processor_clock, regfile_clock;
wire [7:0] clks;
clocks u_clocks(
.clk_in(clock),
.rst(reset),
.clk_out(clks)
);
assign imem_clock = clks[0];
assign dmem_clock = clks[5];
assign regfile_clock = clks[5];
assign processor_clock = clks[7];
/** IMEM **/
// Figure out how to generate a Quartus syncram component and commit the generated verilog file.
// Make sure you configure it correctly!
wire [11:0] address_imem;
wire [31:0] q_imem;
imem my_imem(
.address (address_imem), // address of data
.clock (imem_clock), // you may need to invert the clock
.q (q_imem) // the raw instruction
);
/** DMEM **/
// Figure out how to generate a Quartus syncram component and commit the generated verilog file.
// Make sure you configure it correctly!
wire [11:0] address_dmem;
wire [31:0] data;
wire wren;
wire [31:0] q_dmem;
dmem my_dmem(
.address (address_dmem), // address of data
.clock (dmem_clock), // may need to invert the clock
.data (data), // data you want to write
.wren (wren), // write enable
.q (q_dmem) // data from dmem
);
/** REGFILE **/
// Instantiate your regfile
wire ctrl_writeEnable;
wire [4:0] ctrl_writeReg, ctrl_readRegA, ctrl_readRegB;
wire [31:0] data_writeReg;
wire [31:0] data_readRegA, data_readRegB;
regfile my_regfile(
regfile_clock,
ctrl_writeEnable,
reset,
ctrl_writeReg,
ctrl_readRegA,
ctrl_readRegB,
data_writeReg,
data_readRegA,
data_readRegB
);
/** PROCESSOR **/
processor my_processor(
// Control signals
processor_clock, // I: The master clock
reset, // I: A reset signal
// Imem
address_imem, // O: The address of the data to get from imem
q_imem, // I: The data from imem
// Dmem
address_dmem, // O: The address of the data to get or put from/to dmem
data, // O: The data to write to dmem
wren, // O: Write enable for dmem
q_dmem, // I: The data from dmem
// Regfile
ctrl_writeEnable, // O: Write enable for regfile
ctrl_writeReg, // O: Register to write to in regfile
ctrl_readRegA, // O: Register to read from port A of regfile
ctrl_readRegB, // O: Register to read from port B of regfile
data_writeReg, // O: Data to write to for regfile
data_readRegA, // I: Data from port A of regfile
data_readRegB // I: Data from port B of regfile
);
endmodule