From 221874ba4b8ce0b91cac96c225858c7ff8f0dfc2 Mon Sep 17 00:00:00 2001 From: YRabbit Date: Sat, 25 Oct 2025 16:36:46 +1000 Subject: [PATCH] Gowin. Handle the WRITE_MODE. Process the WRITE_MODE in the GW5A series in a more concise manner. You can check it in the same way as in https://github.com/YosysHQ/yosys/pull/5440 Signed-off-by: YRabbit --- techlibs/gowin/Makefile.inc | 1 - techlibs/gowin/brams.txt | 12 ++++-- techlibs/gowin/brams_gw5a.txt | 69 ----------------------------------- techlibs/gowin/synth_gowin.cc | 2 +- 4 files changed, 9 insertions(+), 75 deletions(-) delete mode 100644 techlibs/gowin/brams_gw5a.txt diff --git a/techlibs/gowin/Makefile.inc b/techlibs/gowin/Makefile.inc index 08893e73f..df1b79317 100644 --- a/techlibs/gowin/Makefile.inc +++ b/techlibs/gowin/Makefile.inc @@ -10,6 +10,5 @@ $(eval $(call add_share_file,share/gowin,techlibs/gowin/arith_map.v)) $(eval $(call add_share_file,share/gowin,techlibs/gowin/brams_map.v)) $(eval $(call add_share_file,share/gowin,techlibs/gowin/brams_map_gw5a.v)) $(eval $(call add_share_file,share/gowin,techlibs/gowin/brams.txt)) -$(eval $(call add_share_file,share/gowin,techlibs/gowin/brams_gw5a.txt)) $(eval $(call add_share_file,share/gowin,techlibs/gowin/lutrams_map.v)) $(eval $(call add_share_file,share/gowin,techlibs/gowin/lutrams.txt)) diff --git a/techlibs/gowin/brams.txt b/techlibs/gowin/brams.txt index 435d3b5cf..ee76dd73a 100644 --- a/techlibs/gowin/brams.txt +++ b/techlibs/gowin/brams.txt @@ -19,8 +19,10 @@ ram block $__GOWIN_SP_ { portoption "WRITE_MODE" 1 { rdwr new; } - portoption "WRITE_MODE" 2 { - rdwr old; + ifndef gw5a { + portoption "WRITE_MODE" 2 { + rdwr old; + } } } } @@ -46,8 +48,10 @@ ram block $__GOWIN_DP_ { portoption "WRITE_MODE" 1 { rdwr new; } - portoption "WRITE_MODE" 2 { - rdwr old; + ifndef gw5a { + portoption "WRITE_MODE" 2 { + rdwr old; + } } } } diff --git a/techlibs/gowin/brams_gw5a.txt b/techlibs/gowin/brams_gw5a.txt deleted file mode 100644 index 2747ea451..000000000 --- a/techlibs/gowin/brams_gw5a.txt +++ /dev/null @@ -1,69 +0,0 @@ -ram block $__GOWIN_SP_ { - abits 14; - widths 1 2 4 9 18 36 per_port; - cost 128; - init no_undef; - port srsw "A" { - clock posedge; - clken; - option "RESET_MODE" "SYNC" { - rdsrst zero ungated; - } - option "RESET_MODE" "ASYNC" { - rdarst zero; - } - rdinit zero; - portoption "WRITE_MODE" 0 { - rdwr no_change; - } - portoption "WRITE_MODE" 1 { - rdwr new; - } - } -} - -ram block $__GOWIN_DP_ { - abits 14; - widths 1 2 4 9 18 per_port; - cost 128; - init no_undef; - port srsw "A" "B" { - clock posedge; - clken; - option "RESET_MODE" "SYNC" { - rdsrst zero ungated; - } - option "RESET_MODE" "ASYNC" { - rdarst zero; - } - rdinit zero; - portoption "WRITE_MODE" 0 { - rdwr no_change; - } - portoption "WRITE_MODE" 1 { - rdwr new; - } - } -} - -ram block $__GOWIN_SDP_ { - abits 14; - widths 1 2 4 9 18 36 per_port; - cost 128; - init no_undef; - port sr "R" { - clock posedge; - clken; - option "RESET_MODE" "SYNC" { - rdsrst zero ungated; - } - option "RESET_MODE" "ASYNC" { - rdarst zero; - } - rdinit zero; - } - port sw "W" { - clock posedge; - clken; - } -} diff --git a/techlibs/gowin/synth_gowin.cc b/techlibs/gowin/synth_gowin.cc index 4e925daab..b9902659c 100644 --- a/techlibs/gowin/synth_gowin.cc +++ b/techlibs/gowin/synth_gowin.cc @@ -263,7 +263,7 @@ struct SynthGowinPass : public ScriptPass if (nolutram) args += " -no-auto-distributed"; } - run(stringf("memory_libmap -lib +/gowin/lutrams.txt -lib +/gowin/brams%s.txt", family == "gw5a" ? "_gw5a" : "") + args, "(-no-auto-block if -nobram, -no-auto-distributed if -nolutram)"); + run(stringf("memory_libmap -lib +/gowin/lutrams.txt -lib +/gowin/brams.txt -D %s", family) + args, "(-no-auto-block if -nobram, -no-auto-distributed if -nolutram)"); run(stringf("techmap -map +/gowin/lutrams_map.v -map +/gowin/brams_map%s.v", family == "gw5a" ? "_gw5a" : "")); }