mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
Simplifyinf bin2gray interface
- Using gray/bin as inputs was cute, but not useful when actually instantiating and reading the code. in/out works better.
This commit is contained in:
parent
3ccd72016e
commit
0432f22c67
@ -8,12 +8,17 @@
|
|||||||
module oh_bin2gray #(parameter DW = 32 // width of data inputs
|
module oh_bin2gray #(parameter DW = 32 // width of data inputs
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
input [DW-1:0] bin, //binary encoded input
|
input [DW-1:0] in, //binary encoded input
|
||||||
output [DW-1:0] gray //gray encoded output
|
output [DW-1:0] out //gray encoded output
|
||||||
);
|
);
|
||||||
|
|
||||||
reg [DW-1:0] gray;
|
reg [DW-1:0] gray;
|
||||||
|
wire [DW-1:0] bin;
|
||||||
|
|
||||||
integer i;
|
integer i;
|
||||||
|
|
||||||
|
assign bin[DW-1:0] = in[DW-1:0];
|
||||||
|
assign out[DW-1:0] = gray[DW-1:0];
|
||||||
|
|
||||||
always @*
|
always @*
|
||||||
begin
|
begin
|
||||||
|
@ -7,13 +7,18 @@
|
|||||||
|
|
||||||
module oh_gray2bin #(parameter DW = 32) // width of data inputs
|
module oh_gray2bin #(parameter DW = 32) // width of data inputs
|
||||||
(
|
(
|
||||||
input [DW-1:0] gray,//gray encoded input
|
input [DW-1:0] in, //gray encoded input
|
||||||
output [DW-1:0] bin //binary encoded output
|
output [DW-1:0] out //binary encoded output
|
||||||
);
|
);
|
||||||
|
|
||||||
reg [DW-1:0] bin;
|
reg [DW-1:0] bin;
|
||||||
|
wire [DW-1:0] gray;
|
||||||
|
|
||||||
integer i,j;
|
integer i,j;
|
||||||
|
|
||||||
|
assign gray[DW-1:0] = in[DW-1:0];
|
||||||
|
assign out[DW-1:0] = bin[DW-1:0];
|
||||||
|
|
||||||
always @*
|
always @*
|
||||||
begin
|
begin
|
||||||
bin[DW-1] = gray[DW-1];
|
bin[DW-1] = gray[DW-1];
|
||||||
@ -24,7 +29,7 @@ module oh_gray2bin #(parameter DW = 32) // width of data inputs
|
|||||||
bin[i] = bin[i] ^ gray [j];
|
bin[i] = bin[i] ^ gray [j];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule // oh_gray2bin
|
endmodule // oh_gray2bin
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user