1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00
myhdl/example/manual/GrayIncReg.v

57 lines
942 B
Coq
Raw Normal View History

2008-11-22 22:40:25 +01:00
// File: GrayIncReg.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 GrayIncReg (
graycnt,
enable,
clock,
reset
);
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
output [7:0] graycnt;
reg [7:0] graycnt;
input enable;
input clock;
input reset;
reg [7:0] graycnt_comb;
reg [7:0] gray_inc_1_bincnt;
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
always @(posedge clock, negedge reset) begin: GRAYINCREG_GRAY_INC_1_INC_1_INCLOGIC
2012-12-21 14:36:07 +01:00
if (reset == 0) begin
2008-11-22 22:40:25 +01:00
gray_inc_1_bincnt <= 0;
end
else begin
if (enable) begin
2012-12-21 15:06:18 +01:00
gray_inc_1_bincnt <= (gray_inc_1_bincnt + 1);
2008-11-22 22:40:25 +01:00
end
end
end
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
always @(gray_inc_1_bincnt) begin: GRAYINCREG_GRAY_INC_1_BIN2GRAY_1_LOGIC
integer i;
reg [9-1:0] Bext;
Bext = 9'h0;
Bext = gray_inc_1_bincnt;
for (i=0; i<8; i=i+1) begin
graycnt_comb[i] = (Bext[(i + 1)] ^ Bext[i]);
2008-11-22 22:40:25 +01:00
end
end
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
always @(posedge clock) begin: GRAYINCREG_REG_1
graycnt <= graycnt_comb;
end
endmodule