-
Notifications
You must be signed in to change notification settings - Fork 0
/
exmem.v
33 lines (30 loc) · 918 Bytes
/
exmem.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: University of Utah
// Engineer: Jacob Sanders
//
// Design Name: Program Memory
// Module Name: exmem
// Project Name: CS3710
// Description:
//////////////////////////////////////////////////////////////////////////////////
module exmem #(parameter WIDTH = 16, RAM_ADDR_BITS = 13)
(input clk, en,
input memwrite,
input [RAM_ADDR_BITS-1:0] adr, pcaddr,
input [WIDTH-1:0] writedata,
output reg [WIDTH-1:0] programout,
output reg [WIDTH-1:0] instruction
);
reg [WIDTH-1:0] program_ram [(2**RAM_ADDR_BITS)-1:0];
initial
$readmemh("program.dat", program_ram);
always @(posedge clk) begin
if (en) begin
if (memwrite)
program_ram[adr] <= writedata;
programout <= program_ram[adr];
end
instruction <= program_ram[pcaddr];
end
endmodule