From 9d0bca97755c928b803ebfa0d70ec21c4977e631 Mon Sep 17 00:00:00 2001 From: YRabbit Date: Sat, 6 Jul 2024 18:58:21 +1000 Subject: [PATCH 1/7] Gowin. Add an energy saving primitive We add a BANDGAP primitive used to turn off power to OSC, PLL and other things on some GOWIN chips. We also mark this primitive and GSR as keep. Signed-off-by: YRabbit --- techlibs/gowin/cells_sim.v | 6 +++++- techlibs/gowin/cells_xtra.py | 2 +- techlibs/gowin/cells_xtra.v | 4 ---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/techlibs/gowin/cells_sim.v b/techlibs/gowin/cells_sim.v index b26869080..4c017e2ab 100644 --- a/techlibs/gowin/cells_sim.v +++ b/techlibs/gowin/cells_sim.v @@ -867,8 +867,12 @@ module ODDRC(D0, D1, CLEAR, TX, CLK, Q0, Q1); parameter INIT = 0; endmodule +(* blackbox, keep *) module GSR (input GSRI); - wire GSRO = GSRI; +endmodule + +(* blackbox, keep *) +module BANDGAP (input BGEN); endmodule (* abc9_box, lib_whitebox *) diff --git a/techlibs/gowin/cells_xtra.py b/techlibs/gowin/cells_xtra.py index 4d117e428..224ece02f 100644 --- a/techlibs/gowin/cells_xtra.py +++ b/techlibs/gowin/cells_xtra.py @@ -13,7 +13,7 @@ class State(Enum): IN_MODULE = auto() IN_PARAMETER = auto() -_skip = { 'ALU', 'DFF', 'DFFC', 'DFFCE', 'DFFE', 'DFFN', 'DFFNC', 'DFFNCE', +_skip = { 'ALU', 'BANDGAP', 'DFF', 'DFFC', 'DFFCE', 'DFFE', 'DFFN', 'DFFNC', 'DFFNCE', 'DFFNE', 'DFFNP', 'DFFNPE', 'DFFNR', 'DFFNRE', 'DFFNS', 'DFFNSE', 'DFFP', 'DFFPE', 'DFFR', 'DFFRE', 'DFFS', 'DFFSE', 'DP', 'DPX9', 'ELVDS_OBUF', 'GND', 'GSR', 'IBUF', 'IDDR', 'IDDRC', 'IDES10', diff --git a/techlibs/gowin/cells_xtra.v b/techlibs/gowin/cells_xtra.v index 4b89b8098..639014dc1 100644 --- a/techlibs/gowin/cells_xtra.v +++ b/techlibs/gowin/cells_xtra.v @@ -1687,10 +1687,6 @@ endmodule module ADC (...); endmodule -module BANDGAP (...); -input BGEN; -endmodule - module CLKDIV2 (...); parameter GSREN = "false"; input HCLKIN, RESETN; From 19bbdd8800c45dd06b1572c5dbf9663607335bb1 Mon Sep 17 00:00:00 2001 From: YRabbit Date: Thu, 11 Jul 2024 21:39:44 +1000 Subject: [PATCH 2/7] Gowin. Add the DCS primitive Not so much adding the primitive itself, but only its DCS_MODE parameter, without which an error occurs. Signed-off-by: YRabbit --- techlibs/gowin/cells_sim.v | 11 +++++++++++ techlibs/gowin/cells_xtra.v | 6 ------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/techlibs/gowin/cells_sim.v b/techlibs/gowin/cells_sim.v index b26869080..d4e035051 100644 --- a/techlibs/gowin/cells_sim.v +++ b/techlibs/gowin/cells_sim.v @@ -1901,3 +1901,14 @@ output OSCOUT; parameter FREQ_DIV = 100; parameter REGULATOR_EN = 1'b0; endmodule + +(* blackbox *) +module DCS (CLK0, CLK1, CLK2, CLK3, CLKSEL, SELFORCE, CLKOUT); +input CLK0, CLK1, CLK2, CLK3, SELFORCE; +input [3:0] CLKSEL; +output CLKOUT; +parameter DCS_MODE = "RISING"; +endmodule + + + diff --git a/techlibs/gowin/cells_xtra.v b/techlibs/gowin/cells_xtra.v index 4b89b8098..cf914f38e 100644 --- a/techlibs/gowin/cells_xtra.v +++ b/techlibs/gowin/cells_xtra.v @@ -1564,12 +1564,6 @@ parameter IDLE = 4'd0, RD_S2 = 4'd12; endmodule -module DCS (...); -input CLK0, CLK1, CLK2, CLK3, SELFORCE; -input [3:0] CLKSEL; -output CLKOUT; -endmodule - module DQCE (...); input CLKIN; input CE; From 9d15f1d6ac4a9ff2e1f87cda8c366659027fb76f Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 12 Jul 2024 10:52:03 +0200 Subject: [PATCH 3/7] Makefile: reproducible .gitcommit --- .gitcommit | 2 +- Makefile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitcommit b/.gitcommit index 46b7856fb..6828f88dc 100644 --- a/.gitcommit +++ b/.gitcommit @@ -1 +1 @@ -$Format:%h$ +$Format:%H$ diff --git a/Makefile b/Makefile index 96c133da9..25a039256 100644 --- a/Makefile +++ b/Makefile @@ -150,7 +150,7 @@ YOSYS_VER := 0.43+3 # will have this file in its unexpanded form tough, in which case we fall # back to calling git directly. TARBALL_GIT_REV := $(shell cat $(YOSYS_SRC)/.gitcommit) -ifeq ($(TARBALL_GIT_REV),$$Format:%h$$) +ifneq ($(findstring "Format:",$(TARBALL_GIT_REV)),) GIT_REV := $(shell GIT_DIR=$(YOSYS_SRC)/.git git rev-parse --short=9 HEAD || echo UNKNOWN) else GIT_REV := $(TARBALL_GIT_REV) @@ -773,10 +773,10 @@ check-git-abc: exit 1; \ elif git -C "$(YOSYS_SRC)" submodule status abc 2>/dev/null | grep -q '^ '; then \ exit 0; \ - elif [ -f "$(YOSYS_SRC)/abc/.gitcommit" ] && ! grep -q '\$$Format:%h\$$' "$(YOSYS_SRC)/abc/.gitcommit"; then \ + elif [ -f "$(YOSYS_SRC)/abc/.gitcommit" ] && ! grep -q '\$$Format:%[hH]\$$' "$(YOSYS_SRC)/abc/.gitcommit"; then \ echo "'abc' comes from a tarball. Continuing."; \ exit 0; \ - elif [ -f "$(YOSYS_SRC)/abc/.gitcommit" ] && grep -q '\$$Format:%h\$$' "$(YOSYS_SRC)/abc/.gitcommit"; then \ + elif [ -f "$(YOSYS_SRC)/abc/.gitcommit" ] && grep -q '\$$Format:%[hH]\$$' "$(YOSYS_SRC)/abc/.gitcommit"; then \ echo "Error: 'abc' is not configured as a git submodule."; \ echo "To resolve this:"; \ echo "1. Back up your changes: Save any modifications from the 'abc' directory to another location."; \ From 7d9ba37fa0291b49ec59217dfe1eb43180ad1edd Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 12 Jul 2024 10:52:13 +0200 Subject: [PATCH 4/7] abc: bump for reproducilbe .gitcommit --- abc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abc b/abc index 237d81397..28d955ca9 160000 --- a/abc +++ b/abc @@ -1 +1 @@ -Subproject commit 237d81397fcc85dd3894bf1a449d2955cd3df02d +Subproject commit 28d955ca97a1c4be3aed4062aec0241a734fac5d From 0cd55e1d7ccbd08e78a213dba3f8dd0d6479a8b0 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 12 Jul 2024 11:00:36 +0200 Subject: [PATCH 5/7] Makefile: fix --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 25a039256..fdb78a986 100644 --- a/Makefile +++ b/Makefile @@ -150,7 +150,7 @@ YOSYS_VER := 0.43+3 # will have this file in its unexpanded form tough, in which case we fall # back to calling git directly. TARBALL_GIT_REV := $(shell cat $(YOSYS_SRC)/.gitcommit) -ifneq ($(findstring "Format:",$(TARBALL_GIT_REV)),) +ifneq ($(findstring Format:,$(TARBALL_GIT_REV)),) GIT_REV := $(shell GIT_DIR=$(YOSYS_SRC)/.git git rev-parse --short=9 HEAD || echo UNKNOWN) else GIT_REV := $(TARBALL_GIT_REV) From ec32c9a0567621b4aadb180588a1faa559c5447e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 17 Jul 2024 18:26:12 +0200 Subject: [PATCH 6/7] Makefile: do install `bitpattern.h` --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 66e6c91ae..3e6555562 100644 --- a/Makefile +++ b/Makefile @@ -579,6 +579,7 @@ S = endif $(eval $(call add_include_file,kernel/binding.h)) +$(eval $(call add_include_file,kernel/bitpattern.h)) $(eval $(call add_include_file,kernel/cellaigs.h)) $(eval $(call add_include_file,kernel/celledges.h)) $(eval $(call add_include_file,kernel/celltypes.h)) From 28ebefda4ac6f534d1e7d3f00224040df0fc5b81 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:17:55 +0000 Subject: [PATCH 7/7] Bump version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 598ce8432..bd95cd132 100644 --- a/Makefile +++ b/Makefile @@ -148,7 +148,7 @@ ifeq ($(OS), Haiku) CXXFLAGS += -D_DEFAULT_SOURCE endif -YOSYS_VER := 0.43+11 +YOSYS_VER := 0.43+22 # Note: We arrange for .gitcommit to contain the (short) commit hash in # tarballs generated with git-archive(1) using .gitattributes. The git repo