From 4694c6aae7656b22fa94db9a252ed046faf40244 Mon Sep 17 00:00:00 2001 From: David Shah Date: Wed, 13 Jun 2018 12:55:08 +0200 Subject: ice40: Update examples to use packer/pcf Signed-off-by: David Shah --- ice40/blinky.pcf | 6 ++ ice40/blinky.sh | 2 +- ice40/blinky.v | 123 ++----------------------------- ice40/blinky.ys | 8 +- ice40/blinky_map.v | 86 ---------------------- ice40/blinky_nopack.ys | 3 - ice40/blinky_noyspack.sh | 8 -- ice40/chipdb.py | 5 +- ice40/icebreaker.pcf | 9 +++ ice40/icebreaker.v | 185 +++-------------------------------------------- 10 files changed, 37 insertions(+), 398 deletions(-) create mode 100644 ice40/blinky.pcf mode change 100644 => 100755 ice40/blinky.sh delete mode 100644 ice40/blinky_map.v delete mode 100644 ice40/blinky_nopack.ys delete mode 100755 ice40/blinky_noyspack.sh create mode 100644 ice40/icebreaker.pcf diff --git a/ice40/blinky.pcf b/ice40/blinky.pcf new file mode 100644 index 00000000..141dfcc8 --- /dev/null +++ b/ice40/blinky.pcf @@ -0,0 +1,6 @@ +set_io led1 99 +set_io led2 98 +set_io led3 97 +set_io led4 96 +set_io led5 95 +set_io clki 21 diff --git a/ice40/blinky.sh b/ice40/blinky.sh old mode 100644 new mode 100755 index 23ee2cac..a2326fc3 --- a/ice40/blinky.sh +++ b/ice40/blinky.sh @@ -1,7 +1,7 @@ #!/bin/bash set -ex yosys blinky.ys -../nextpnr-ice40 --json blinky.json --asc blinky.asc +../nextpnr-ice40 --json blinky.json --pcf blinky.pcf --asc blinky.asc icepack blinky.asc blinky.bin icebox_vlog blinky.asc > blinky_chip.v iverilog -o blinky_tb blinky_chip.v blinky_tb.v diff --git a/ice40/blinky.v b/ice40/blinky.v index 72bcd662..a45021d2 100644 --- a/ice40/blinky.v +++ b/ice40/blinky.v @@ -1,128 +1,17 @@ module blinky ( - input clk_pin, - output led1_pin, - output led2_pin, - output led3_pin, - output led4_pin, - output led5_pin + input clki, + output led1, + output led2, + output led3, + output led4, + output led5 ); - wire clk, clki; SB_GB clk_gb ( .USER_SIGNAL_TO_GLOBAL_BUFFER(clki), .GLOBAL_BUFFER_OUTPUT(clk) ); - wire led1, led2, led3, led4, led5; - - (* BEL="13_12_io1" *) - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led1_iob ( - .PACKAGE_PIN(led1_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led1), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="13_12_io0" *) - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led2_iob ( - .PACKAGE_PIN(led2_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led2), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="13_11_io1" *) - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led3_iob ( - .PACKAGE_PIN(led3_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led3), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="13_11_io0" *) - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led4_iob ( - .PACKAGE_PIN(led4_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led4), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="13_9_io1" *) - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led5_iob ( - .PACKAGE_PIN(led5_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led5), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="0_8_io1" *) - SB_IO #( - .PIN_TYPE(6'b 0000_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) clk_iob ( - .PACKAGE_PIN(clk_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(), - .D_OUT_1(), - .D_IN_0(clki), - .D_IN_1() - ); - localparam BITS = 5; localparam LOG2DELAY = 22; diff --git a/ice40/blinky.ys b/ice40/blinky.ys index 9c51dc88..bad0a8b4 100644 --- a/ice40/blinky.ys +++ b/ice40/blinky.ys @@ -1,9 +1,3 @@ read_verilog blinky.v -read_verilog -lib +/ice40/cells_sim.v -synth -top blinky -abc -lut 4 -techmap -map blinky_map.v -splitnets -opt_clean -stat +synth_ice40 -top blinky -nocarry write_json blinky.json diff --git a/ice40/blinky_map.v b/ice40/blinky_map.v deleted file mode 100644 index 9d8bf65e..00000000 --- a/ice40/blinky_map.v +++ /dev/null @@ -1,86 +0,0 @@ -module \$_DFF_P_ (input D, C, output Q); - ICESTORM_LC #( - .LUT_INIT(2), - .NEG_CLK(0), - .CARRY_ENABLE(0), - .DFF_ENABLE(1), - .SET_NORESET(0), - .ASYNC_SR(0) - ) _TECHMAP_REPLACE_ ( - .I0(D), - .CLK(C), - .O(Q), - - .I1(), - .I2(), - .I3(), - .CIN(), - .CEN(), - .SR(), - .LO(), - .COUT() - ); -endmodule - -module \$lut (A, Y); - parameter WIDTH = 0; - parameter LUT = 0; - - input [WIDTH-1:0] A; - output Y; - - generate - if (WIDTH == 1) begin - ICESTORM_LC #( - .LUT_INIT(LUT), - .NEG_CLK(0), - .CARRY_ENABLE(0), - .DFF_ENABLE(0), - .SET_NORESET(0), - .ASYNC_SR(0) - ) _TECHMAP_REPLACE_ ( - .I0(A[0]), .I1(), .I2(), .I3(), .O(Y), - .CLK(), .CIN(), .CEN(), .SR(), .LO(), .COUT() - ); - end - if (WIDTH == 2) begin - ICESTORM_LC #( - .LUT_INIT(LUT), - .NEG_CLK(0), - .CARRY_ENABLE(0), - .DFF_ENABLE(0), - .SET_NORESET(0), - .ASYNC_SR(0) - ) _TECHMAP_REPLACE_ ( - .I0(A[0]), .I1(A[1]), .I2(), .I3(), .O(Y), - .CLK(), .CIN(), .CEN(), .SR(), .LO(), .COUT() - ); - end - if (WIDTH == 3) begin - ICESTORM_LC #( - .LUT_INIT(LUT), - .NEG_CLK(0), - .CARRY_ENABLE(0), - .DFF_ENABLE(0), - .SET_NORESET(0), - .ASYNC_SR(0) - ) _TECHMAP_REPLACE_ ( - .I0(A[0]), .I1(A[1]), .I2(A[2]), .I3(), .O(Y), - .CLK(), .CIN(), .CEN(), .SR(), .LO(), .COUT() - ); - end - if (WIDTH == 4) begin - ICESTORM_LC #( - .LUT_INIT(LUT), - .NEG_CLK(0), - .CARRY_ENABLE(0), - .DFF_ENABLE(0), - .SET_NORESET(0), - .ASYNC_SR(0) - ) _TECHMAP_REPLACE_ ( - .I0(A[0]), .I1(A[1]), .I2(A[2]), .I3(A[3]), .O(Y), - .CLK(), .CIN(), .CEN(), .SR(), .LO(), .COUT() - ); - end - endgenerate -endmodule diff --git a/ice40/blinky_nopack.ys b/ice40/blinky_nopack.ys deleted file mode 100644 index aeaa518b..00000000 --- a/ice40/blinky_nopack.ys +++ /dev/null @@ -1,3 +0,0 @@ -read_verilog blinky.v -synth_ice40 -nocarry -top blinky -write_json blinky_nopack.json diff --git a/ice40/blinky_noyspack.sh b/ice40/blinky_noyspack.sh deleted file mode 100755 index 00824ae9..00000000 --- a/ice40/blinky_noyspack.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -set -ex -yosys blinky_nopack.ys -../nextpnr-ice40 --json blinky_nopack.json --asc blinky.asc --pack -icepack blinky.asc blinky.bin -icebox_vlog blinky.asc > blinky_chip.v -iverilog -o blinky_tb blinky_chip.v blinky_tb.v -vvp -N ./blinky_tb diff --git a/ice40/chipdb.py b/ice40/chipdb.py index 946197d3..d50deaa1 100644 --- a/ice40/chipdb.py +++ b/ice40/chipdb.py @@ -410,16 +410,17 @@ packageinfo = [] for package in packages: name, pins = package + safename = re.sub("[^A-Za-z0-9]", "_", name) pins_info = [] for pin in pins: pinname, x, y, z = pin pin_bel = "%d_%d_io%d" % (x, y, z) bel_idx = bel_name.index(pin_bel) pins_info.append('{"%s", %d}' % (pinname, bel_idx)) - print("static PackagePinPOD package_%s_pins[%d] = {" % (name, len(pins_info))) + print("static PackagePinPOD package_%s_pins[%d] = {" % (safename, len(pins_info))) print(",\n".join(pins_info)) print("};") - packageinfo.append('{"%s", %d, package_%s_pins}' % (name, len(pins_info), name)) + packageinfo.append('{"%s", %d, package_%s_pins}' % (name, len(pins_info), safename)) tilegrid = [] for y in range(dev_height): diff --git a/ice40/icebreaker.pcf b/ice40/icebreaker.pcf new file mode 100644 index 00000000..4564c84e --- /dev/null +++ b/ice40/icebreaker.pcf @@ -0,0 +1,9 @@ +set_io led1 27 +set_io led2 25 +set_io led3 21 +set_io led4 23 +set_io led5 26 +set_io clki 35 +set_io btn1 20 +set_io btn2 19 +set_io btn3 18 diff --git a/ice40/icebreaker.v b/ice40/icebreaker.v index f7b788a1..2ad2397d 100644 --- a/ice40/icebreaker.v +++ b/ice40/icebreaker.v @@ -1,179 +1,16 @@ module icebreaker ( - input clk_pin, - input btn1_pin, - input btn2_pin, - input btn3_pin, - output led1_pin, - output led2_pin, - output led3_pin, - output led4_pin, - output led5_pin + input clki, + input btn1, + input btn2, + input btn3, + output led1, + output led2, + output led3, + output led4, + output led5 ); - wire clk, clk_pre, led1, led2, led3, led4, led5, btn1, btn2, btn3; - - (* BEL="18_31_io1" *) //27 - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led1_iob ( - .PACKAGE_PIN(led1_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led1), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="19_31_io1" *) //25 - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led2_iob ( - .PACKAGE_PIN(led2_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led2), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="18_0_io1" *) //21 - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led3_iob ( - .PACKAGE_PIN(led3_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led3), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="19_31_io0" *) //23 - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led4_iob ( - .PACKAGE_PIN(led4_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led4), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="18_31_io0" *) //26 - SB_IO #( - .PIN_TYPE(6'b 0110_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) led5_iob ( - .PACKAGE_PIN(led5_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(led5), - .D_OUT_1(), - .D_IN_0(), - .D_IN_1() - ); - - (* BEL="12_31_io1" *) //35 - SB_IO #( - .PIN_TYPE(6'b 0000_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) clk_iob ( - .PACKAGE_PIN(clk_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(), - .D_OUT_1(), - .D_IN_0(clk_pre), - .D_IN_1() - ); - - (* BEL="19_0_io1" *) //20 - SB_IO #( - .PIN_TYPE(6'b 0000_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) btn1_iob ( - .PACKAGE_PIN(btn1_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(), - .D_OUT_1(), - .D_IN_0(btn1), - .D_IN_1() - ); - - (* BEL="21_0_io1" *) //19 - SB_IO #( - .PIN_TYPE(6'b 0000_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) btn2_iob ( - .PACKAGE_PIN(btn2_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(), - .D_OUT_1(), - .D_IN_0(btn2), - .D_IN_1() - ); - - (* BEL="22_0_io1" *) //18 - SB_IO #( - .PIN_TYPE(6'b 0000_01), - .PULLUP(1'b0), - .NEG_TRIGGER(1'b0) - ) btn3_iob ( - .PACKAGE_PIN(btn3_pin), - .LATCH_INPUT_VALUE(), - .CLOCK_ENABLE(), - .INPUT_CLK(), - .OUTPUT_CLK(), - .OUTPUT_ENABLE(), - .D_OUT_0(), - .D_OUT_1(), - .D_IN_0(btn3), - .D_IN_1() - ); - - SB_GB clk_gb(.USER_SIGNAL_TO_GLOBAL_BUFFER(clk_pre), .GLOBAL_BUFFER_OUTPUT(clk)); + wire clk; + SB_GB clk_gb(.USER_SIGNAL_TO_GLOBAL_BUFFER(clki), .GLOBAL_BUFFER_OUTPUT(clk)); localparam BITS = 5; localparam LOG2DELAY = 22; -- cgit v1.2.3