diff options
author | Clifford Wolf <clifford@clifford.at> | 2017-11-21 18:19:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-21 18:19:47 +0100 |
commit | 6e9a2da5c46edf00f1dc87c86053b5edbc17d5d7 (patch) | |
tree | b94fdbf6f316b9758e8afd848d8c900343469f07 /examples | |
parent | 9a2a325acb846936431c4aa5843184034be25d5c (diff) | |
parent | 9184fbdf404c0e94326919c92a27d3292994cdf1 (diff) | |
download | icestorm-6e9a2da5c46edf00f1dc87c86053b5edbc17d5d7.tar.gz icestorm-6e9a2da5c46edf00f1dc87c86053b5edbc17d5d7.tar.bz2 icestorm-6e9a2da5c46edf00f1dc87c86053b5edbc17d5d7.zip |
Merge pull request #109 from daveshah1/up5k
Support for new UltraPlus features
Diffstat (limited to 'examples')
-rw-r--r-- | examples/up5k/.gitignore | 4 | ||||
-rw-r--r-- | examples/up5k/example.v | 10 | ||||
-rw-r--r-- | examples/up5k/up5k.pcf | 3 | ||||
-rw-r--r-- | examples/up5k_mac16/.gitignore | 12 | ||||
-rw-r--r-- | examples/up5k_mac16/Makefile (renamed from examples/up5k/Makefile) | 16 | ||||
-rw-r--r-- | examples/up5k_mac16/mac16.pcf | 4 | ||||
-rw-r--r-- | examples/up5k_mac16/mac16.v | 71 | ||||
-rw-r--r-- | examples/up5k_rgb/.gitignore | 12 | ||||
-rw-r--r-- | examples/up5k_rgb/Makefile | 36 | ||||
-rw-r--r-- | examples/up5k_rgb/rgb.pcf | 3 | ||||
-rw-r--r-- | examples/up5k_rgb/rgb.v | 81 |
11 files changed, 227 insertions, 25 deletions
diff --git a/examples/up5k/.gitignore b/examples/up5k/.gitignore deleted file mode 100644 index c1fa30b..0000000 --- a/examples/up5k/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -example.bin -example.blif -example.asc -example.rpt diff --git a/examples/up5k/example.v b/examples/up5k/example.v deleted file mode 100644 index 01b76b8..0000000 --- a/examples/up5k/example.v +++ /dev/null @@ -1,10 +0,0 @@ -module top ( - input btn, - output LED0, - output LED1, -); - -assign LED0 = !btn; -assign LED1 = btn; - -endmodule diff --git a/examples/up5k/up5k.pcf b/examples/up5k/up5k.pcf deleted file mode 100644 index b1d1263..0000000 --- a/examples/up5k/up5k.pcf +++ /dev/null @@ -1,3 +0,0 @@ -set_io LED0 12 -set_io LED1 21 -set_io btn 26 diff --git a/examples/up5k_mac16/.gitignore b/examples/up5k_mac16/.gitignore new file mode 100644 index 0000000..dd32bfb --- /dev/null +++ b/examples/up5k_mac16/.gitignore @@ -0,0 +1,12 @@ +*.bin +*.blif +*.asc +*.rpt +*.glb +*.psb +*.sdf +*.vsb +*.bin +*.tmp/ +*.exp +*.vlog diff --git a/examples/up5k/Makefile b/examples/up5k_mac16/Makefile index ea16f06..06c9ed7 100644 --- a/examples/up5k/Makefile +++ b/examples/up5k_mac16/Makefile @@ -1,12 +1,12 @@ -PROJ = example -PIN_DEF = up5k.pcf +PROJ = mac16 +PIN_DEF = mac16.pcf DEVICE = up5k -# Relative paths for easier development without messing with installed version -ARACHNE = ../../../arachne-pnr/bin/arachne-pnr -ARACHNE_ARGS = -c ../../icebox/chipdb-5k.txt -ICEPACK = ../../icepack/icepack -ICETIME = ../../icetime/icetime -ICEPROG = ../../iceprog/iceprog + +ARACHNE = arachne-pnr +ARACHNE_ARGS = +ICEPACK = icepack +ICETIME = icetime +ICEPROG = iceprog all: $(PROJ).bin diff --git a/examples/up5k_mac16/mac16.pcf b/examples/up5k_mac16/mac16.pcf new file mode 100644 index 0000000..5e21181 --- /dev/null +++ b/examples/up5k_mac16/mac16.pcf @@ -0,0 +1,4 @@ +set_io clk 44 +set_io rstn 27 +set_io LED1 12 +set_io LED2 13 diff --git a/examples/up5k_mac16/mac16.v b/examples/up5k_mac16/mac16.v new file mode 100644 index 0000000..0323fc3 --- /dev/null +++ b/examples/up5k_mac16/mac16.v @@ -0,0 +1,71 @@ +module top( + input clk, + input rstn, + output LED1, + output LED2); + +wire reset = !rstn; + +wire [15:0] A = 16'd999; +wire [15:0] B = 16'd12345; +wire [31:0] RES = 32'd12332655; + +wire [31:0] dsp_out; + +SB_MAC16 i_sbmac16 + ( + .A(A), + .B(B), + .C(16'b0), + .D(16'b0), + .CLK(clk), + .CE(1'b1), + .IRSTTOP(reset), + .IRSTBOT(reset), + .ORSTTOP(reset), + .ORSTBOT(reset), + .AHOLD(1'b0), + .BHOLD(1'b0), + .CHOLD(1'b0), + .DHOLD(1'b0), + .OHOLDTOP(1'b0), + .OHOLDBOT(1'b0), + .OLOADTOP(1'b0), + .OLOADBOT(1'b0), + .ADDSUBTOP(1'b0), + .ADDSUBBOT(1'b0), + .CO(), + .CI(1'b0), + .O(dsp_out) + ); + +//16x16 => 32 unsigned pipelined multiply +defparam i_sbmac16. B_SIGNED = 1'b0; +defparam i_sbmac16. A_SIGNED = 1'b0; +defparam i_sbmac16. MODE_8x8 = 1'b0; + +defparam i_sbmac16. BOTADDSUB_CARRYSELECT = 2'b00; +defparam i_sbmac16. BOTADDSUB_UPPERINPUT = 1'b0; +defparam i_sbmac16. BOTADDSUB_LOWERINPUT = 2'b00; +defparam i_sbmac16. BOTOUTPUT_SELECT = 2'b11; + +defparam i_sbmac16. TOPADDSUB_CARRYSELECT = 2'b00; +defparam i_sbmac16. TOPADDSUB_UPPERINPUT = 1'b0; +defparam i_sbmac16. TOPADDSUB_LOWERINPUT = 2'b00; +defparam i_sbmac16. TOPOUTPUT_SELECT = 2'b11; + +defparam i_sbmac16. PIPELINE_16x16_MULT_REG2 = 1'b1; +defparam i_sbmac16. PIPELINE_16x16_MULT_REG1 = 1'b1; +defparam i_sbmac16. BOT_8x8_MULT_REG = 1'b1; +defparam i_sbmac16. TOP_8x8_MULT_REG = 1'b1; +defparam i_sbmac16. D_REG = 1'b0; +defparam i_sbmac16. B_REG = 1'b1; +defparam i_sbmac16. A_REG = 1'b1; +defparam i_sbmac16. C_REG = 1'b0; + +assign LED1 = (dsp_out == RES) ? 1'b1 : 1'b0; +assign LED2 = 1'b0; + + + +endmodule diff --git a/examples/up5k_rgb/.gitignore b/examples/up5k_rgb/.gitignore new file mode 100644 index 0000000..dd32bfb --- /dev/null +++ b/examples/up5k_rgb/.gitignore @@ -0,0 +1,12 @@ +*.bin +*.blif +*.asc +*.rpt +*.glb +*.psb +*.sdf +*.vsb +*.bin +*.tmp/ +*.exp +*.vlog diff --git a/examples/up5k_rgb/Makefile b/examples/up5k_rgb/Makefile new file mode 100644 index 0000000..51c1f72 --- /dev/null +++ b/examples/up5k_rgb/Makefile @@ -0,0 +1,36 @@ +PROJ = rgb +PIN_DEF = rgb.pcf +DEVICE = up5k + +ARACHNE = arachne-pnr +ARACHNE_ARGS = +ICEPACK = icepack +ICETIME = icetime +ICEPROG = iceprog + +all: $(PROJ).bin + +%.blif: %.v + yosys -p 'synth_ice40 -top top -blif $@' $< + +%.asc: $(PIN_DEF) %.blif + $(ARACHNE) $(ARACHNE_ARGS) -d $(subst up,,$(subst hx,,$(subst lp,,$(DEVICE)))) -o $@ -p $^ + +%.bin: %.asc + $(ICEPACK) $< $@ + +%.rpt: %.asc + $(ICETIME) -d $(DEVICE) -mtr $@ $< + +prog: $(PROJ).bin + $(ICEPROG) -S $< + +sudo-prog: $(PROJ).bin + @echo 'Executing prog as root!!!' + sudo $(ICEPROG) -S $< + +clean: + rm -f $(PROJ).blif $(PROJ).asc $(PROJ).rpt $(PROJ).bin + +.SECONDARY: +.PHONY: all prog clean diff --git a/examples/up5k_rgb/rgb.pcf b/examples/up5k_rgb/rgb.pcf new file mode 100644 index 0000000..0954260 --- /dev/null +++ b/examples/up5k_rgb/rgb.pcf @@ -0,0 +1,3 @@ +set_io RGB0 39 +set_io RGB1 40 +set_io RGB2 41 diff --git a/examples/up5k_rgb/rgb.v b/examples/up5k_rgb/rgb.v new file mode 100644 index 0000000..fa29fba --- /dev/null +++ b/examples/up5k_rgb/rgb.v @@ -0,0 +1,81 @@ +module top( + output RGB0, RGB1, RGB2 +); + +wire clk; + +SB_HFOSC inthosc ( + .CLKHFPU(1'b1), + .CLKHFEN(1'b1), + .CLKHF(clk) +); + +localparam counter_width = 32; + +reg [counter_width-1:0] ctr; + +always@(posedge clk) +begin + ctr <= ctr + 1; +end + +localparam pwm_width = 12; + +localparam pwm_max = (2**pwm_width) - 1; +localparam pwm_max_div4 = (2**(pwm_width-2)) - 1; + + +wire [1:0] phase = ctr[counter_width - 1 : counter_width - 2]; +wire [pwm_width-1:0] fade = ctr[counter_width - 3 : counter_width - (2 + pwm_width)]; +wire [pwm_width-1:0] fade_div4 = ctr[counter_width - 3 : counter_width - (pwm_width)]; + +wire [pwm_width-1:0] r_val, g_val, b_val; + +// Fade R->G->B->W-> +assign r_val = (phase == 0) ? pwm_max_div4 + (3 * fade_div4) : + (phase == 1) ? pwm_max - fade : + (phase == 3) ? fade_div4 : + 0; + +assign g_val = (phase == 0) ? pwm_max_div4 - fade_div4: + (phase == 1) ? fade : + (phase == 2) ? pwm_max - fade : + (phase == 3) ? fade_div4 : + 0; + +assign b_val = (phase == 0) ? pwm_max_div4 - fade_div4: + (phase == 2) ? fade : + (phase == 3) ? pwm_max - (3 * fade_div4) : + 0; + +reg [pwm_width-1:0] pwm_ctr; + +reg pwm_r, pwm_g, pwm_b; + +always@(posedge clk) +begin + pwm_ctr <= pwm_ctr + 1; + pwm_r <= (pwm_ctr < r_val) ? 1'b1 : 1'b0; + pwm_g <= (pwm_ctr < g_val) ? 1'b1 : 1'b0; + pwm_b <= (pwm_ctr < b_val) ? 1'b1 : 1'b0; +end + +SB_RGBA_DRV RGBA_DRIVER ( + .CURREN(1'b1), + .RGBLEDEN(1'b1), + .RGB0PWM(pwm_g), + .RGB1PWM(pwm_b), + .RGB2PWM(pwm_r), + .RGB0(RGB0), + .RGB1(RGB1), + .RGB2(RGB2) +); + + +defparam RGBA_DRIVER.CURRENT_MODE = "0b1"; +defparam RGBA_DRIVER.RGB0_CURRENT = "0b000111"; +defparam RGBA_DRIVER.RGB1_CURRENT = "0b000111"; +defparam RGBA_DRIVER.RGB2_CURRENT = "0b000111"; + + +endmodule |