Last active
November 5, 2023 10:11
-
-
Save grav/2f97f9df1315d79815f57eec2353eea8 to your computer and use it in GitHub Desktop.
Blink for ICE40 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
// No default net type is assumed for undeclared identifiers | |
`default_nettype none | |
module top ( | |
// led matrix see the .pcf file in projectfolder for physical pins | |
// Gotcha: removing aled here stops blinking from working, eventhough aled doesn't seem to be in use(!) | |
output [3:0] kled, | |
output [3:0] aled, | |
); | |
// use ice40up5k 48Mhz internal oscillator | |
wire clk; | |
SB_HFOSC inthosc ( .CLKHFPU(1'b1), .CLKHFEN(1'b1), .CLKHF(clk) ); | |
// Led | |
wire kled_tri; // connect katode via SB_IO modules to allow high impadance or 3.3V | |
// configure/connect IO Pins for LED driver logic | |
SB_IO | |
#( .PIN_TYPE(6'b 1010_01), .PULLUP(1'b 0) ) | |
led_io1 ( .PACKAGE_PIN(kled[0]), .OUTPUT_ENABLE(kled_tri), .D_OUT_0(1'b1) ); | |
reg [22:0] counter; | |
always @(posedge clk) begin | |
counter<=counter+1 ; | |
if (counter == 0) begin | |
kled_tri = ~kled_tri; | |
end | |
end | |
endmodule // end top module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment