-
Notifications
You must be signed in to change notification settings - Fork 18
/
ram_primitives.v
71 lines (48 loc) · 1.3 KB
/
ram_primitives.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
module const_bit_32_0(input clk,
input rst,
output [31:0] out);
assign out = 0;
endmodule
module const_bit_32_1(input clk,
input rst,
output [31:0] out);
assign out = 1;
endmodule
module const_bit_32_10(input clk,
input rst,
output [31:0] out);
assign out = 10;
endmodule
module reg_bit_32(input clk,
input rst,
input [31:0] in,
input en,
output [31:0] current);
reg [31:0] data;
always @(posedge clk) begin
if (en) begin
data <= in;
end
end
assign current = data;
endmodule
module adder_bit_32(input clk,
input rst,
input [31:0] in0,
input [31:0] in1,
output [31:0] out);
assign out = in0 + in1;
endmodule
module reg_32(input clk,
input rst,
input [31:0] in,
input en,
output [31:0] out);
reg [31:0] data;
always @(posedge clk) begin
if (en) begin
data <= in;
end
end
assign out = data;
endmodule