mirror of
https://github.com/aolofsson/oh.git
synced 2025-02-07 06:44:09 +08:00
Simplifying bin2gray converter
This commit is contained in:
parent
5744252f91
commit
f21be19c28
@ -13,19 +13,6 @@ module oh_bin2gray
|
|||||||
output [N-1:0] out //gray encoded output
|
output [N-1:0] out //gray encoded output
|
||||||
);
|
);
|
||||||
|
|
||||||
reg [N-1:0] gray;
|
assign out[N-1:0] = in[N-1:0] ^ {1'b0, in[N-1:1]};
|
||||||
wire [N-1:0] bin;
|
|
||||||
|
|
||||||
integer i;
|
|
||||||
|
|
||||||
assign bin[N-1:0] = in[N-1:0];
|
|
||||||
assign out[N-1:0] = gray[N-1:0];
|
|
||||||
|
|
||||||
always @*
|
|
||||||
begin
|
|
||||||
gray[N-1] = bin[N-1];
|
|
||||||
for (i=0; i<(N-1); i=i+1)
|
|
||||||
gray[i] = bin[i] ^ bin[i+1];
|
|
||||||
end
|
|
||||||
|
|
||||||
endmodule // oh_bin2gray
|
endmodule // oh_bin2gray
|
||||||
|
Loading…
x
Reference in New Issue
Block a user