From cdf688363968ee8895d8e6fe08178cff8fc9ee75 Mon Sep 17 00:00:00 2001 From: David Shah Date: Thu, 16 Nov 2017 14:03:11 +0000 Subject: UltraPlus DSPs working --- examples/up5k_mac16/.gitignore | 12 +++++++ examples/up5k_mac16/mac16.pcf | 4 +++ examples/up5k_mac16/mac16.v | 71 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 examples/up5k_mac16/.gitignore create mode 100644 examples/up5k_mac16/mac16.pcf create mode 100644 examples/up5k_mac16/mac16.v (limited to 'examples') 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_mac16/mac16.pcf b/examples/up5k_mac16/mac16.pcf new file mode 100644 index 0000000..24b9b45 --- /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 \ No newline at end of file diff --git a/examples/up5k_mac16/mac16.v b/examples/up5k_mac16/mac16.v new file mode 100644 index 0000000..73740e3 --- /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 \ No newline at end of file -- cgit v1.2.3 From c71db50a27600885ea4e84d9744a4a4417af02c6 Mon Sep 17 00:00:00 2001 From: David Shah Date: Fri, 17 Nov 2017 11:27:40 +0000 Subject: Add UltraPlus LED driver support and demo --- examples/up5k_rgb/.gitignore | 12 +++++++ examples/up5k_rgb/Makefile | 36 ++++++++++++++++++++ examples/up5k_rgb/rgb.pcf | 3 ++ examples/up5k_rgb/rgb.v | 81 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 examples/up5k_rgb/.gitignore create mode 100644 examples/up5k_rgb/Makefile create mode 100644 examples/up5k_rgb/rgb.pcf create mode 100644 examples/up5k_rgb/rgb.v (limited to 'examples') 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..711ce5a --- /dev/null +++ b/examples/up5k_rgb/Makefile @@ -0,0 +1,36 @@ +PROJ = rgb +PIN_DEF = rgb.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 + +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..cfdb874 --- /dev/null +++ b/examples/up5k_rgb/rgb.pcf @@ -0,0 +1,3 @@ +set_io RGB0 39 +set_io RGB1 40 +set_io RGB2 41 \ No newline at end of file diff --git a/examples/up5k_rgb/rgb.v b/examples/up5k_rgb/rgb.v new file mode 100644 index 0000000..c83b943 --- /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 = 30; + +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 = "0b000001"; +defparam RGBA_DRIVER.RGB1_CURRENT = "0b000011"; +defparam RGBA_DRIVER.RGB2_CURRENT = "0b000011"; + + +endmodule \ No newline at end of file -- cgit v1.2.3 From da7a2a9d0db95d6a172286eaddd6e930a27ea752 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 20 Nov 2017 09:43:54 +0000 Subject: Fix whitespace and a couple of typos --- examples/up5k_mac16/mac16.pcf | 2 +- examples/up5k_mac16/mac16.v | 2 +- examples/up5k_rgb/rgb.pcf | 2 +- examples/up5k_rgb/rgb.v | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/up5k_mac16/mac16.pcf b/examples/up5k_mac16/mac16.pcf index 24b9b45..5e21181 100644 --- a/examples/up5k_mac16/mac16.pcf +++ b/examples/up5k_mac16/mac16.pcf @@ -1,4 +1,4 @@ set_io clk 44 set_io rstn 27 set_io LED1 12 -set_io LED2 13 \ No newline at end of file +set_io LED2 13 diff --git a/examples/up5k_mac16/mac16.v b/examples/up5k_mac16/mac16.v index 73740e3..0323fc3 100644 --- a/examples/up5k_mac16/mac16.v +++ b/examples/up5k_mac16/mac16.v @@ -68,4 +68,4 @@ assign LED2 = 1'b0; -endmodule \ No newline at end of file +endmodule diff --git a/examples/up5k_rgb/rgb.pcf b/examples/up5k_rgb/rgb.pcf index cfdb874..0954260 100644 --- a/examples/up5k_rgb/rgb.pcf +++ b/examples/up5k_rgb/rgb.pcf @@ -1,3 +1,3 @@ set_io RGB0 39 set_io RGB1 40 -set_io RGB2 41 \ No newline at end of file +set_io RGB2 41 diff --git a/examples/up5k_rgb/rgb.v b/examples/up5k_rgb/rgb.v index c83b943..81920cb 100644 --- a/examples/up5k_rgb/rgb.v +++ b/examples/up5k_rgb/rgb.v @@ -78,4 +78,4 @@ defparam RGBA_DRIVER.RGB1_CURRENT = "0b000011"; defparam RGBA_DRIVER.RGB2_CURRENT = "0b000011"; -endmodule \ No newline at end of file +endmodule -- cgit v1.2.3 From 9184fbdf404c0e94326919c92a27d3292994cdf1 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 20 Nov 2017 09:51:03 +0000 Subject: Tidy up 5k examples --- examples/up5k/.gitignore | 4 ---- examples/up5k/Makefile | 36 ------------------------------------ examples/up5k/example.v | 10 ---------- examples/up5k/up5k.pcf | 3 --- examples/up5k_mac16/Makefile | 36 ++++++++++++++++++++++++++++++++++++ examples/up5k_rgb/Makefile | 12 ++++++------ examples/up5k_rgb/rgb.v | 8 ++++---- 7 files changed, 46 insertions(+), 63 deletions(-) delete mode 100644 examples/up5k/.gitignore delete mode 100644 examples/up5k/Makefile delete mode 100644 examples/up5k/example.v delete mode 100644 examples/up5k/up5k.pcf create mode 100644 examples/up5k_mac16/Makefile (limited to 'examples') 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/Makefile b/examples/up5k/Makefile deleted file mode 100644 index ea16f06..0000000 --- a/examples/up5k/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -PROJ = example -PIN_DEF = up5k.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 - -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/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/Makefile b/examples/up5k_mac16/Makefile new file mode 100644 index 0000000..06c9ed7 --- /dev/null +++ b/examples/up5k_mac16/Makefile @@ -0,0 +1,36 @@ +PROJ = mac16 +PIN_DEF = mac16.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/Makefile b/examples/up5k_rgb/Makefile index 711ce5a..51c1f72 100644 --- a/examples/up5k_rgb/Makefile +++ b/examples/up5k_rgb/Makefile @@ -1,12 +1,12 @@ PROJ = rgb PIN_DEF = rgb.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_rgb/rgb.v b/examples/up5k_rgb/rgb.v index 81920cb..fa29fba 100644 --- a/examples/up5k_rgb/rgb.v +++ b/examples/up5k_rgb/rgb.v @@ -10,7 +10,7 @@ SB_HFOSC inthosc ( .CLKHF(clk) ); -localparam counter_width = 30; +localparam counter_width = 32; reg [counter_width-1:0] ctr; @@ -73,9 +73,9 @@ SB_RGBA_DRV RGBA_DRIVER ( defparam RGBA_DRIVER.CURRENT_MODE = "0b1"; -defparam RGBA_DRIVER.RGB0_CURRENT = "0b000001"; -defparam RGBA_DRIVER.RGB1_CURRENT = "0b000011"; -defparam RGBA_DRIVER.RGB2_CURRENT = "0b000011"; +defparam RGBA_DRIVER.RGB0_CURRENT = "0b000111"; +defparam RGBA_DRIVER.RGB1_CURRENT = "0b000111"; +defparam RGBA_DRIVER.RGB2_CURRENT = "0b000111"; endmodule -- cgit v1.2.3