-
Notifications
You must be signed in to change notification settings - Fork 0
/
addr_cmd_mem.v
53 lines (47 loc) · 981 Bytes
/
addr_cmd_mem.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
// MIT License
// Copyright (c) 2019 Cyril Jean
// SPDX-License-Identifier: MIT
module addr_cmd_mem
(
input reset_n,
// Host port
input clk_a,
input [31:0] dat_in_a,
input [9:0] address_a,
output [31:0] dat_out_a,
input wr_a,
// Encoder port
input clk_b,
input [31:0] dat_in_b,
input [9:0] address_b,
output [31:0] dat_out_b,
input wr_b
);
reg [31:0] memory[512:0];
reg [31:0] dat_out_a;
reg [31:0] dat_out_b;
//
// Host port
//
always @ (posedge clk_a)
begin
dat_out_a <= memory[address_a];
if (wr_a)
begin
dat_out_a <= dat_in_a;
memory[address_a] <= dat_in_a;
end
end
//
// Encoder port
//
always @ (posedge clk_b)
begin
dat_out_b <= memory[address_b];
if (wr_b)
begin
dat_out_b <= dat_in_b;
memory[address_b] <= dat_in_b;
end
end
endmodule