-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmybuf.sv
executable file
·83 lines (73 loc) · 1.33 KB
/
mybuf.sv
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
`define DEBUG_RAM
//`timescale 1ns / 1fs
module ebr_buffer
(
input wire [7:0] DataInA,
input wire [7:0] DataInB,
input wire [10:0] AddressA,
input wire [10:0] AddressB,
input wire ClockA,
input wire ClockB,
input wire ClockEnA,
input wire ClockEnB,
input wire WrA,
input wire WrB,
input wire ResetA,
input wire ResetB,
// input disp,
output wire [7:0] QA,
output wire [7:0] QB
);
// Declare the RAM variable
reg [7:0] ram[0:2047];
reg [7:0] q_a, q_b;
assign QA = q_a;
assign QB = q_b;
// Port A
always_ff @ (posedge ClockA)
begin
if(ClockEnA)
begin
if (WrA)
begin
ram[AddressA] <= DataInA;
q_a <= DataInA;
end
else
begin
q_a <= ram[AddressA];
end
end
end
// Port B
always_ff @ (posedge ClockB)
begin
if (ClockEnB)
begin
if (WrB)
begin
ram[AddressB] <= DataInB;
q_b <= DataInB;
end
else
begin
q_b <= ram[AddressB];
end
end
end
/*`ifdef DEBUG_RAM
always @ (posedge disp)
begin: named
// integer i;
if (disp)
begin
for(int i=0; i<10; i=i+1)
$display ("mem[%0d] = %0d", i, ram[i]);
for(int i=51; i<68; i=i+1)
$display ("mem[%0d] = %0d", i, ram[i]);
for (int i=2040; i<2048; i=i+1)
$display ("mem[%0d] = %0d", i, ram[i]);
end
end
`endif*/
endmodule