Created
June 2, 2018 20:05
-
-
Save yellowcrescent/35a397c35618c9298fa9ef09bf3d0fa5 to your computer and use it in GitHub Desktop.
lcd blinky example in verilog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`timescale 1ps / 1ps | |
module lcd_clock ( | |
input wire clk, | |
input wire rst, | |
output reg pulse | |
); | |
parameter clk_freq = 26'd12000000; // X1 = 12MHz | |
parameter lcd_freq = 26'd4000; // target output frequency * 2 (2KHz = 4000) | |
reg [25:0] clk_div; | |
always @ (posedge clk or posedge rst) | |
if (rst) begin | |
clk_div <= 0; | |
pulse <= 0; | |
end else begin | |
if (clk_div >= clk_freq/lcd_freq) begin | |
clk_div <= 0; | |
pulse <= ~pulse; | |
end else begin | |
clk_div <= clk_div + 1; | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment