2008-11-22 22:40:25 +01:00
|
|
|
// File: Inc.v
|
2010-07-02 13:24:04 +02:00
|
|
|
// Generated by MyHDL 0.7dev
|
|
|
|
// Date: Fri Jul 2 13:23:50 2010
|
|
|
|
|
2008-11-22 22:40:25 +01:00
|
|
|
|
|
|
|
`timescale 1ns/10ps
|
|
|
|
|
|
|
|
module Inc (
|
|
|
|
count,
|
|
|
|
enable,
|
|
|
|
clock,
|
|
|
|
reset
|
|
|
|
);
|
2010-07-02 13:24:04 +02:00
|
|
|
// Incrementer with enable.
|
|
|
|
//
|
|
|
|
// count -- output
|
|
|
|
// enable -- control input, increment when 1
|
|
|
|
// clock -- clock input
|
|
|
|
// reset -- asynchronous reset input
|
|
|
|
// n -- counter max value
|
2008-11-22 22:40:25 +01:00
|
|
|
|
|
|
|
output [7:0] count;
|
|
|
|
reg [7:0] count;
|
|
|
|
input enable;
|
|
|
|
input clock;
|
|
|
|
input reset;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-02 13:24:04 +02:00
|
|
|
|
|
|
|
|
2008-11-22 22:40:25 +01:00
|
|
|
always @(posedge clock, negedge reset) begin: INC_INCLOGIC
|
|
|
|
if ((reset == 0)) begin
|
|
|
|
count <= 0;
|
|
|
|
end
|
|
|
|
else begin
|
|
|
|
if (enable) begin
|
|
|
|
count <= ((count + 1) % 256);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|