@@ -40,21 +40,6 @@ struct BitstreamBackend
40
40
BitstreamBackend (Context *ctx, GateMateImpl *uarch, const std::string &device, std::ostream &out)
41
41
: ctx(ctx), uarch(uarch), device(device), out(out) {};
42
42
43
- void get_bitstream_tile (int x, int y, int &b_x, int &b_y)
44
- {
45
- // Edge blocks are bit bigger
46
- if (x == -2 )
47
- x++;
48
- if (x == 163 )
49
- x--;
50
- if (y == -2 )
51
- y++;
52
- if (y == 131 )
53
- y--;
54
- b_x = (x + 1 ) / 2 ;
55
- b_y = (y + 1 ) / 2 ;
56
- }
57
-
58
43
std::vector<bool > int_to_bitvector (int val, int size)
59
44
{
60
45
std::vector<bool > bv;
@@ -76,28 +61,16 @@ struct BitstreamBackend
76
61
return bv;
77
62
}
78
63
79
- CfgLoc getConfigLoc (Context *ctx, int tile)
64
+ CfgLoc getConfigLoc (int tile)
80
65
{
81
- int x0, y0 ;
82
- int bx, by;
83
- tile_xy (ctx->chip_info , tile, x0, y0 );
84
- get_bitstream_tile (x0 - 2 , y0 - 2 , bx, by);
66
+ auto ti = *uarch->tile_extra_data (tile);
85
67
CfgLoc loc;
86
- loc.die = 0 ;
87
- loc.x = bx ;
88
- loc.y = by ;
68
+ loc.die = ti. die ;
69
+ loc.x = ti. bit_x ;
70
+ loc.y = ti. bit_y ;
89
71
return loc;
90
72
}
91
73
92
- int getInTileIndex (Context *ctx, int tile)
93
- {
94
- int x0, y0 ;
95
- tile_xy (ctx->chip_info , tile, x0, y0 );
96
- x0 -= 2 - 1 ;
97
- y0 -= 2 - 1 ;
98
- return (x0 % 2 ) * 2 + (y0 % 2 ) + 1 ;
99
- }
100
-
101
74
void write_bitstream ()
102
75
{
103
76
ChipConfig cc;
@@ -111,7 +84,7 @@ struct BitstreamBackend
111
84
cc.configs [0 ].add_word (" GPIO.BANK_W1" , int_to_bitvector (1 , 1 ));
112
85
cc.configs [0 ].add_word (" GPIO.BANK_W2" , int_to_bitvector (1 , 1 ));
113
86
for (auto &cell : ctx->cells ) {
114
- CfgLoc loc = getConfigLoc (ctx, cell.second .get ()->bel .tile );
87
+ CfgLoc loc = getConfigLoc (cell.second .get ()->bel .tile );
115
88
auto ¶ms = cell.second .get ()->params ;
116
89
switch (cell.second ->type .index ) {
117
90
case id_CC_IBUF.index :
@@ -127,9 +100,9 @@ struct BitstreamBackend
127
100
}
128
101
break ;
129
102
case id_CPE.index : {
130
- int x = getInTileIndex (ctx, cell.second .get ()->bel .tile );
103
+ int id = uarch-> tile_extra_data ( cell.second .get ()->bel .tile )-> prim_id ;
131
104
for (auto &p : params) {
132
- cc.tiles [loc].add_word (stringf (" CPE%d.%s" , x , p.first .c_str (ctx)), p.second .as_bits ());
105
+ cc.tiles [loc].add_word (stringf (" CPE%d.%s" , id , p.first .c_str (ctx)), p.second .as_bits ());
133
106
}
134
107
} break ;
135
108
case id_BUFG.index :
@@ -169,20 +142,28 @@ struct BitstreamBackend
169
142
chip_pip_info (ctx->chip_info , pip).extra_data .get ());
170
143
if (extra_data.type == PipExtra::PIP_EXTRA_MUX && (extra_data.flags & MUX_VISIBLE)) {
171
144
IdString name = IdString (extra_data.name );
172
- CfgLoc loc = getConfigLoc (ctx, pip.tile );
145
+ CfgLoc loc = getConfigLoc (pip.tile );
173
146
std::string word = name.c_str (ctx);
174
147
if (extra_data.flags & MUX_CONFIG) {
175
- cc.configs [loc.die ].add_word (word, int_to_bitvector (extra_data.value , extra_data.bits ));
148
+ cc.configs [loc.die ].add_word (word, int_to_bitvector (extra_data.value , extra_data.bits ));
176
149
} else {
177
- int x = getInTileIndex (ctx, pip.tile );
150
+ int id = uarch-> tile_extra_data ( pip.tile )-> prim_id ;
178
151
if (boost::starts_with (word, " IM." ))
179
- boost::replace_all (word, " IM." , stringf (" IM%d." , x));
180
- if (boost::starts_with (word, " OM." ))
181
- boost::replace_all (word, " OM." , stringf (" OM%d." , x));
182
- if (boost::starts_with (word, " IOES." ))
183
- boost::replace_all (word, " IOES." , " IOES1." );
184
- if (boost::starts_with (word, " CPE." ))
185
- boost::replace_all (word, " CPE." , stringf (" CPE%d." , x));
152
+ boost::replace_all (word, " IM." , stringf (" IM%d." , id));
153
+ else if (boost::starts_with (word, " OM." ))
154
+ boost::replace_all (word, " OM." , stringf (" OM%d." , id));
155
+ else if (boost::starts_with (word, " CPE." ))
156
+ boost::replace_all (word, " CPE." , stringf (" CPE%d." , id));
157
+ else if (boost::starts_with (word, " IOES." ))
158
+ boost::replace_all (word, " IOES." , stringf (" IOES%d." , id));
159
+ else if (boost::starts_with (word, " LES." ))
160
+ boost::replace_all (word, " LES." , stringf (" LES%d." , id));
161
+ else if (boost::starts_with (word, " BES." ))
162
+ boost::replace_all (word, " BES." , stringf (" BES%d." , id));
163
+ else if (boost::starts_with (word, " RES." ))
164
+ boost::replace_all (word, " RES." , stringf (" RES%d." , id));
165
+ else if (boost::starts_with (word, " TES." ))
166
+ boost::replace_all (word, " TES." , stringf (" TES%d." , id));
186
167
cc.tiles [loc].add_word (word, int_to_bitvector (extra_data.value , extra_data.bits ));
187
168
}
188
169
}
0 commit comments