1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00
myhdl/example/manual/bin2gray.v

38 lines
518 B
Coq
Raw Normal View History

2008-11-22 22:40:25 +01:00
// File: bin2gray.v
2012-12-21 14:36:07 +01:00
// Generated by MyHDL 0.8dev
2012-12-21 15:06:18 +01:00
// Date: Fri Dec 21 15:02:38 2012
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
`timescale 1ns/10ps
module bin2gray (
B,
G
);
2010-07-02 13:24:04 +02:00
// Gray encoder.
//
// B -- input intbv signal, binary encoded
// G -- output intbv signal, gray encoded
// width -- bit width
2008-11-22 22:40:25 +01:00
input [7:0] B;
output [7:0] G;
reg [7:0] G;
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
always @(B) begin: BIN2GRAY_LOGIC
integer i;
reg [9-1:0] Bext;
Bext = 9'h0;
Bext = B;
for (i=0; i<8; i=i+1) begin
G[i] = (Bext[(i + 1)] ^ Bext[i]);
2008-11-22 22:40:25 +01:00
end
end
endmodule