-
Notifications
You must be signed in to change notification settings - Fork 399
/
Copy pathreverse_vector.sv
39 lines (29 loc) · 1.01 KB
/
reverse_vector.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
//------------------------------------------------------------------------------
// reverse_vector.sv
// Konstantin Pavlov, [email protected]
//------------------------------------------------------------------------------
// INFO ------------------------------------------------------------------------
// "Physically" reverses signal order within multi-bit bus
// Thus in[7] signal becomes out[0], in[6] becomes out[1] and vise-versa
// Module is no doubt synthesizable, but its instance does NOT occupy any FPGA resources!
/* --- INSTANTIATION TEMPLATE BEGIN ---
reverse_vector #(
.WIDTH( 8 ) // WIDTH must be >=2
) RV1 (
.in( smth[7:0] ),
.out( htms[7:0] ) // reversed bit order
);
--- INSTANTIATION TEMPLATE END ---*/
module reverse_vector #( parameter
WIDTH = 8
)(
input [(WIDTH-1):0] in,
output logic [(WIDTH-1):0] out
);
integer i;
always_comb begin
for (i = 0; i < WIDTH ; i++) begin : gen_reverse
out[i] = in[(WIDTH-1)-i];
end // for
end // always_comb
endmodule