{"action":"created","issue":{"url":"https://api.github.com/repos/YosysHQ/nextpnr/issues/116","repository_url":"https://api.github.com/repos/YosysHQ/nextpnr","labels_url":"https://api.github.com/repos/YosysHQ/nextpnr/issues/116/labels{/name}","comments_url":"https://api.github.com/repos/YosysHQ/nextpnr/issues/116/comments","events_url":"https://api.github.com/repos/YosysHQ/nextpnr/issues/116/events","html_url":"https://github.com/YosysHQ/nextpnr/issues/116","id":380812126,"node_id":"MDU6SXNzdWUzODA4MTIxMjY=","number":116,"title":"Smarter initial placement for ice40","user":{"login":"smunaut","id":129013,"node_id":"MDQ6VXNlcjEyOTAxMw==","avatar_url":"https://avatars1.githubusercontent.com/u/129013?v=4","gravatar_id":"","url":"https://api.github.com/users/smunaut","html_url":"https://github.com/smunaut","followers_url":"https://api.github.com/users/smunaut/followers","following_url":"https://api.github.com/users/smunaut/following{/other_user}","gists_url":"https://api.github.com/users/smunaut/gists{/gist_id}","starred_url":"https://api.github.com/users/smunaut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smunaut/subscriptions","organizations_url":"https://api.github.com/users/smunaut/orgs","repos_url":"https://api.github.com/users/smunaut/repos","events_url":"https://api.github.com/users/smunaut/events{/privacy}","received_events_url":"https://api.github.com/users/smunaut/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-14T17:41:01Z","updated_at":"2018-11-15T06:01:47Z","closed_at":null,"author_association":"NONE","body":"I have a design that fails initial placement. This is mostly because of incompatible CE lines for the flipflops and it is for a LP384 which doesn't have a lot of resources and I'm trying to pack 330 LCs in there.\r\n\r\nicecube2 does produce a valid and working bitstream, so that design _can_ definitely fit. But looking at the output, it seems that the synthesizer of icecube 2 also produces a slightly smaller result, so this might help as well.\r\n\r\nAnyway, what I've been toying with is to add a `int Arch::scoreBelForCell(CellInfo *cell, BelId bel) const\r\n` method that returns a \"score\" of how good a BEL is for a CELL. and then I use that score in the initial placement instead of random.\r\n\r\nCurrently my attempt looks like this : \r\n\r\n```\r\nint Arch::scoreBelForCell(CellInfo *cell, BelId bel) const\r\n{       \r\n    /* Only process LC */\r\n    if (cell->type != id_ICESTORM_LC)\r\n        return 0;\r\n    \r\n    NPNR_ASSERT(getBelType(bel) == id_ICESTORM_LC);\r\n        \r\n    /* If the cell doesn't have any FF, no preferences */\r\n    if (!cell->lcInfo.dffEnable)\r\n        return 8;\r\n\r\n    /* If the cell has a FF, then count how many bels would be used in that slice */\r\n    size_t num_cells = 0; \r\n\r\n    Loc bel_loc = getBelLocation(bel);\r\n    for (auto bel_other : getBelsByTile(bel_loc.x, bel_loc.y)) {\r\n        CellInfo *ci_other = getBoundBelCell(bel_other);\r\n        if (ci_other != nullptr && bel_other != bel)\r\n            num_cells++;\r\n    }\r\n\r\n    return 8 - num_cells;\r\n}\r\n```\r\n\r\nBasically if the cell has flipflops, it will try to pack it in the same slice as other cells that have the same constraints. If the cell doesn't have a FF, then doesn't matter, it can get ripped up and replaced somewhere else if needed.\r\n\r\nThis does help. I went from finding placement for only ~ 230 LCs to about 320 LCs. Still not enough for my design though.\r\n"},"comment":{"url":"https://api.github.com/repos/YosysHQ/nextpnr/issues/comments/438927807","html_url":"https://github.com/YosysHQ/nextpnr/issues/116#issuecomment-438927807","issue_url":"https://api.github.com/repos/YosysHQ/nextpnr/issues/116","id":438927807,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODkyNzgwNw==","user":{"login":"eddiehung","id":6740044,"node_id":"MDQ6VXNlcjY3NDAwNDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6740044?v=4","gravatar_id":"","url":"https://api.github.com/users/eddiehung","html_url":"https://github.com/eddiehung","followers_url":"https://api.github.com/users/eddiehung/followers","following_url":"https://api.github.com/users/eddiehung/following{/other_user}","gists_url":"https://api.github.com/users/eddiehung/gists{/gist_id}","starred_url":"https://api.github.com/users/eddiehung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddiehung/subscriptions","organizations_url":"https://api.github.com/users/eddiehung/orgs","repos_url":"https://api.github.com/users/eddiehung/repos","events_url":"https://api.github.com/users/eddiehung/events{/privacy}","received_events_url":"https://api.github.com/users/eddiehung/received_events","type":"User","site_admin":false},"created_at":"2018-11-15T06:01:47Z","updated_at":"2018-11-15T06:01:47Z","author_association":"COLLABORATOR","body":"Thanks! I just had a quick look, and it looks like initial placement requires legality of cen/sr/clk/clk-polarity/num-inputs. In a super congested design like yours, the current algorithm fails to find a valid location because it cannot find a compatible with all the (or empty) logic block.\r\nYou can see this in the GUI:\r\n![image](https://user-images.githubusercontent.com/6740044/48533291-ac488500-e858-11e8-8109-8d5e0581cc3c.png)\r\nLet us rethink what (and take a peek at what arachne does) to do in this case..."}}
{"actor":{"display_login":"eddiehung"}}