blob: 7f27be9c8bdbe564eb6b86a8305c20364bde8eb6 (
plain) (
blame)
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
|
module gpr_register(
input clk,
input reg_write_en,
input [2:0]reg_write_dest,
input [15:0]reg_write_data,
input [2:0]reg_read_addr_1,
output [15:0]reg_read_data_1,
input [2:0]reg_read_addr_2,
output [15:0]reg_read_data_2
);
reg [15:0] reg_array[7:0];
integer i;
//set initial values of registers to 0
initial begin
for (i=0; i<8; i=i+1)
reg_array[i] <= 16'd0;
end
//handlr write behaviour
always @(posedge clk) begin
if (reg_write_en) begin
reg_array[reg_write_dest] = reg_write_data;
end
end
assign reg_read_data_1 = reg_array[reg_read_addr_1];
//assign reg_read_data_1 = reg_array[3'b001];
assign reg_read_data_2 = reg_array[reg_read_addr_2];
endmodule
|