Skip to content

Commit

Permalink
added blinky
Browse files Browse the repository at this point in the history
  • Loading branch information
pdmart committed May 12, 2016
1 parent 807cd21 commit 81d6d30
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
# icestorm build files
*.blif
*.bin
*.asc
1 change: 1 addition & 0 deletions blinky/.gitignore
@@ -0,0 +1 @@
build/*
26 changes: 26 additions & 0 deletions blinky/Makefile
@@ -0,0 +1,26 @@
# Project setup
PROJ = blinky
BUILD = ./build
DEVICE = 8k
FOOTPRINT = ct256

# Files
FILES = top.v

.PHONY: all clean burn

all:
# if build folder doesn't exist, create it
mkdir -p $(BUILD)
# synthesize using Yosys
yosys -p "synth_ice40 -top top -blif $(BUILD)/$(PROJ).blif" $(FILES)
# Place and route using arachne
arachne-pnr -d $(DEVICE) -P $(FOOTPRINT) -o $(BUILD)/$(PROJ).asc -p pinmap.pcf $(BUILD)/$(PROJ).blif
# Convert to bitstream using IcePack
icepack $(BUILD)/$(PROJ).asc $(BUILD)/$(PROJ).bin

burn:
iceprog $(BUILD)/$(PROJ).bin

clean:
rm build/*
10 changes: 10 additions & 0 deletions blinky/pinmap.pcf
@@ -0,0 +1,10 @@
# example.pcf
set_io --warn-no-port led1 B5
set_io --warn-no-port led2 B4
set_io --warn-no-port led3 A2
set_io --warn-no-port led4 A1
set_io --warn-no-port led5 C5
set_io --warn-no-port led6 C4
set_io --warn-no-port led7 B3
set_io --warn-no-port led8 C3
set_io --warn-no-port hwclk J3
33 changes: 33 additions & 0 deletions blinky/top.v
@@ -0,0 +1,33 @@
// Blink an LED provided an input clock
/* module */
module top (hwclk, led1, led2, led3, led4, led5, led6, led7, led8 );
/* I/O */
input hwclk;
output led1;
output led2;
output led3;
output led4;
output led5;
output led6;
output led7;
output led8;

/* Counter register */
reg [31:0] counter = 32'b0;

/* LED drivers */
assign led1 = counter[18];
assign led2 = counter[19];
assign led3 = counter[20];
assign led4 = counter[21];
assign led5 = counter[22];
assign led6 = counter[23];
assign led7 = counter[24];
assign led8 = counter[25];

/* always */
always @ (posedge hwclk) begin
counter <= counter + 1;
end

endmodule

0 comments on commit 81d6d30

Please sign in to comment.