aboutsummaryrefslogtreecommitdiffstats
path: root/mistral
diff options
context:
space:
mode:
authorLofty <dan.ravensloft@gmail.com>2022-03-10 10:28:57 +0000
committerLofty <dan.ravensloft@gmail.com>2022-03-12 17:08:20 +0000
commit883f27480274cd6385bce118dc31d260ec9ae832 (patch)
tree635dc5ad6d5919e8cbdbac1dda5defa2fb142098 /mistral
parent3e688a3ac9ae35a894d5c2c19f2d9591b746d8da (diff)
downloadnextpnr-883f27480274cd6385bce118dc31d260ec9ae832.tar.gz
nextpnr-883f27480274cd6385bce118dc31d260ec9ae832.tar.bz2
nextpnr-883f27480274cd6385bce118dc31d260ec9ae832.zip
mistral: M10K initialisation support
Diffstat (limited to 'mistral')
-rw-r--r--mistral/bitstream.cc19
-rw-r--r--mistral/constids.inc1
2 files changed, 18 insertions, 2 deletions
diff --git a/mistral/bitstream.cc b/mistral/bitstream.cc
index 6a2c3825..c5105008 100644
--- a/mistral/bitstream.cc
+++ b/mistral/bitstream.cc
@@ -153,9 +153,24 @@ struct MistralBitgen
cv->bmux_b_set(CycloneV::M10K, pos, CycloneV::DISABLE_UNUSED, bi, 0);
- // Note for future us: the RAM init contents are inverted.
+ auto permute_init = [](int64_t init) -> int64_t {
+ const int permutation[40] = {0, 20, 10, 30, 1, 21, 11, 31, 2, 22, 12, 32, 3, 23, 13, 33, 4, 24, 14, 34,
+ 5, 25, 15, 35, 6, 26, 16, 36, 7, 27, 17, 37, 8, 28, 18, 38, 9, 29, 19, 39};
+
+ int64_t output = 0;
+ for (int bit = 0; bit < 40; bit++)
+ output |= ((init >> permutation[bit]) & 1) << bit;
+ return ~output; // RAM init is inverted.
+ };
+
+ Property init;
+ if (ci->params.count(id_INIT) == 0) {
+ init = Property{0, 10240};
+ } else {
+ init = ci->params.at(id_INIT);
+ }
for (int bi = 0; bi < 256; bi++)
- cv->bmux_r_set(CycloneV::M10K, pos, CycloneV::RAM, bi, 0xffffffffff);
+ cv->bmux_r_set(CycloneV::M10K, pos, CycloneV::RAM, bi, permute_init(init.extract(bi * 40, 40).as_int64()));
}
void write_cells()
diff --git a/mistral/constids.inc b/mistral/constids.inc
index 262fd12a..754a96b3 100644
--- a/mistral/constids.inc
+++ b/mistral/constids.inc
@@ -100,6 +100,7 @@ X(cyclonev_oscillator)
X(cyclonev_hps_interface_mpu_general_purpose)
X(MISTRAL_M10K)
+X(INIT)
X(ADDRSTALLA)
X(ADDRSTALLB)
X(CFG_ABITS)