Skip to content

Instantly share code, notes, and snippets.

@jjhorton
Last active June 27, 2022 19:31
Show Gist options
  • Save jjhorton/6b546071cedb00800551ad31aa7a9232 to your computer and use it in GitHub Desktop.
Save jjhorton/6b546071cedb00800551ad31aa7a9232 to your computer and use it in GitHub Desktop.
Ice Sugar Pro PMod LED Example
`default_nettype none
module blinky(CLK, LED);
input wire CLK;
output wire [7:0] LED;
parameter WIDTH=25;
reg [WIDTH-1:0] counter;
reg [7:0] display;
initial counter = 0;
initial display = 8'b00000001;
always @(posedge CLK)
begin
counter <= counter +1'b1;
if (counter[WIDTH-1] == 1)
begin
// When the counter reaches top value shift the LEd accross one
counter <= 0;
if (display== 8'b10000000)
display <= 8'b00000001;
else
display <= display << 1;
end
end
assign LED = display;
endmodule
LOCATE COMP "CLK" SITE "P6";
IOBUF PORT "CLK" IO_TYPE=LVCMOS33;
LOCATE COMP "LED[0]" SITE "T6";
LOCATE COMP "LED[1]" SITE "P7";
LOCATE COMP "LED[2]" SITE "R5";
LOCATE COMP "LED[3]" SITE "R6";
LOCATE COMP "LED[4]" SITE "R4";
LOCATE COMP "LED[5]" SITE "T4";
LOCATE COMP "LED[6]" SITE "R3";
LOCATE COMP "LED[7]" SITE "T3";
PROJ = blinky
PIN_DEF = icesugarpro.pcf
DEVICE = 25k
PACKAGE = CABGA256
build:
yosys -p 'synth_ecp5 -top blinky -json $(PROJ).json' $(PROJ).v
nextpnr-ecp5 --$(DEVICE) --package $(PACKAGE) --json $(PROJ).json --lpf $(PIN_DEF) --textcfg $(PROJ).config --freq 100
ecppack --compress --bit $(PROJ).bin $(PROJ).config
prog:
ecpdap program --freq 5000 $(PROJ).bin
flash:
ecpdap flash unprotect
ecpdap flash write --freq 5000 $(PROJ).bin
clean:
rm -f $(PROJ).json $(PROJ).asc $(PROJ).rpt $(PROJ).bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment