aboutsummaryrefslogtreecommitdiffstats
path: root/tests/various/memory_word_as_index.v
blob: a99ea95664f78599d8b93a19201b49fb57f73d73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
`define DATA 64'h492e5c4d7747e032

`define GATE(n, expr) \
module gate``n(sel, out); \
	input wire [3:0] sel; \
	output wire out; \
	reg [63:0] bits; \
	reg [5:0] ptrs[15:0]; \
	initial bits = `DATA; \
	initial $readmemh("memory_word_as_index.data", ptrs); \
	assign out = expr; \
endmodule

`GATE(1, bits[ptrs[sel]])
`GATE(2, bits[ptrs[sel][5:0]])
`GATE(3, bits[ptrs[sel]+:1])

module gold(sel, out);
	input wire [3:0] sel;
	output wire out = `DATA >> (sel * 4);
endmodule