{"action":"created","comment":{"url":"https://api.github.com/repos/maxeler/maxpower/pulls/comments/46132690","id":46132690,"diff_hunk":"@@ -0,0 +1,310 @@\n+package maxpower.kernel.mem;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import maxpower.kernel.arithmetic.ConstDenominator;\n+import maxpower.kernel.arithmetic.ConstDenominator.ConstDivModResult;\n+\n+import com.maxeler.maxcompiler.v2.kernelcompiler.Kernel;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.KernelLib;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.stdlib.core.CounterChain;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.stdlib.core.Mem.DualPortMemOutputs;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.stdlib.core.Mem.RamPortMode;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.stdlib.core.Mem.RamPortParams;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.stdlib.core.Mem.RamWriteMode;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.stdlib.core.Stream.OffsetExpr;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.types.base.DFEType;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.types.base.DFEVar;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.types.composite.DFEVector;\n+import com.maxeler.maxcompiler.v2.kernelcompiler.types.composite.DFEVectorType;\n+import com.maxeler.maxcompiler.v2.utils.MathUtils;\n+\n+/**\n+ * Use single buffer to transpose matrices.\n+ */\n+public class Transposer {\n+\n+\tprivate static int offset_counter = 0;\n+\n+\t/**\n+\t * Multi pipe version of the 2D transpose function. Note that hight and width have to be multiples of\n+\t * the number of pipes\n+\t *\n+\t * Example:\n+\t * Assume width of 4 and height of 3, with values\n+\t *\n+\t *\t0\t|\t1\t|\t2\t|\t3\n+\t *\t4\t|\t5\t|\t6\t|\t7\n+\t *\t8\t|\t9\t|\t10\t|\t11\n+\t *\n+\t *\tThen the output will return (after 12 cycles since the output does not hide the latency)\n+\t *\t\t0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11\n+\t *\n+\t * width     fast dimension\n+\t * height    slow dimension\n+\t **/\n+\tpublic static DFEVector<DFEVar> transpose(DFEVector<DFEVar> in, int width, int height) {\n+\t\treturn in.getKernel().stream.offset(transpose(in, width, height, in.getKernel().constant.var(true)),\n+\t\t\t\twidth * height / in.getSize());\n+\t}\n+\n+\t/**\n+\t * Multi pipe version of the 2D transpose function. Note that hight and width have to be multiples of\n+\t * the number of pipes\n+\t *\n+\t * Example:\n+\t * Assume width of 4 and height of 3, with values\n+\t *\n+\t *\t0\t|\t1\t|\t2\t|\t3\n+\t *\t4\t|\t5\t|\t6\t|\t7\n+\t *\t8\t|\t9\t|\t10\t|\t11\n+\t *\n+\t *\tThen the output will return (after 12 cycles since the output does not hide the latency)\n+\t *\t\t0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11\n+\t *\n+\t * width     fast dimension\n+\t * height    slow dimension\n+\t **/\n+\tpublic static DFEVector<DFEVar> transpose(DFEVector<DFEVar> in, int width, int height, DFEVar enable) {\n+\t\tKernelLib owner = in.getKernel();\n+\n+\t\tfinal int N = width * height;\n+\t\tfinal int pipes = in.getSize();\n+\t\tif (!MathUtils.integerMultiple(width, pipes) || !MathUtils.integerMultiple(height, pipes)) {\n+\t\t\tthrow new RuntimeException(\"Width and height have to be a multiple of the number of pipes.\");\n+\t\t}\n+\t\t// double buffered implementation\n+\n+\t\tDFEType addressType = Kernel.dfeUInt(MathUtils.bitsToAddress(2 * (N / pipes)));\n+\t\tCounterChain readCounter = owner.control.count.makeCounterChain(enable);\n+\t\tCounterChain writeCounter = owner.control.count.makeCounterChain(enable);\n+\n+\t\tDFEVar state    = readCounter.addCounter(2,      1);\n+\t\tDFEVar slowRead = readCounter.addCounter(width,  1).cast(addressType);\n+\t\tDFEVar fastRead = readCounter.addCounter(height / pipes, 1).cast(addressType);\n+\n+\t\tDFEVar slowWrite = writeCounter.addCounter(height, 1).cast(addressType);\n+\t\tDFEVar fastWrite = writeCounter.addCounter(width / pipes,  1).cast(addressType);\n+\n+\t\tDFEVar writeAddress = fastWrite + slowWrite * (width / pipes);\n+\n+\t\tConstDivModResult writeRotateDivMod = ConstDenominator.divMod(slowWrite, pipes);\n+\t\twriteRotateDivMod.getQuotient().setReportOnUnused(false);\n+\t\tDFEVar writeRotate = writeRotateDivMod.getRemainder();\n+\t\tConstDivModResult readRotateDivMod = ConstDenominator.divMod(slowRead, pipes);","path":"src/maxpower/kernel/mem/Transposer.maxj","position":95,"original_position":95,"commit_id":"ff7eff126596ce0a24686a5d30814ccc61acd8ad","original_commit_id":"ff7eff126596ce0a24686a5d30814ccc61acd8ad","user":{"login":"stepeh","id":12087956,"avatar_url":"https://avatars.githubusercontent.com/u/12087956?v=3","gravatar_id":"","url":"https://api.github.com/users/stepeh","html_url":"https://github.com/stepeh","followers_url":"https://api.github.com/users/stepeh/followers","following_url":"https://api.github.com/users/stepeh/following{/other_user}","gists_url":"https://api.github.com/users/stepeh/gists{/gist_id}","starred_url":"https://api.github.com/users/stepeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stepeh/subscriptions","organizations_url":"https://api.github.com/users/stepeh/orgs","repos_url":"https://api.github.com/users/stepeh/repos","events_url":"https://api.github.com/users/stepeh/events{/privacy}","received_events_url":"https://api.github.com/users/stepeh/received_events","type":"User","site_admin":false},"body":"In the case where height == width we can save a DivMod here.\r\n","created_at":"2015-11-30T11:30:06Z","updated_at":"2015-11-30T11:30:06Z","html_url":"https://github.com/maxeler/maxpower/pull/39#discussion_r46132690","pull_request_url":"https://api.github.com/repos/maxeler/maxpower/pulls/39","_links":{"self":{"href":"https://api.github.com/repos/maxeler/maxpower/pulls/comments/46132690"},"html":{"href":"https://github.com/maxeler/maxpower/pull/39#discussion_r46132690"},"pull_request":{"href":"https://api.github.com/repos/maxeler/maxpower/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/maxeler/maxpower/pulls/39","id":51097149,"html_url":"https://github.com/maxeler/maxpower/pull/39","diff_url":"https://github.com/maxeler/maxpower/pull/39.diff","patch_url":"https://github.com/maxeler/maxpower/pull/39.patch","issue_url":"https://api.github.com/repos/maxeler/maxpower/issues/39","number":39,"state":"open","locked":false,"title":"Fft","user":{"login":"nilsv","id":14997140,"avatar_url":"https://avatars.githubusercontent.com/u/14997140?v=3","gravatar_id":"","url":"https://api.github.com/users/nilsv","html_url":"https://github.com/nilsv","followers_url":"https://api.github.com/users/nilsv/followers","following_url":"https://api.github.com/users/nilsv/following{/other_user}","gists_url":"https://api.github.com/users/nilsv/gists{/gist_id}","starred_url":"https://api.github.com/users/nilsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilsv/subscriptions","organizations_url":"https://api.github.com/users/nilsv/orgs","repos_url":"https://api.github.com/users/nilsv/repos","events_url":"https://api.github.com/users/nilsv/events{/privacy}","received_events_url":"https://api.github.com/users/nilsv/received_events","type":"User","site_admin":false},"body":"We still want to make changes to the Interface. This will probably only require changes to FftFactory4Pipes and Encoder.\r\nThe remaining classes should be pretty \"final\" (Yes I know that there are probably 1000 things you want me to change).","created_at":"2015-11-18T15:19:32Z","updated_at":"2015-11-30T11:30:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f4703f8f485b26e4aee1a0e04fcb865b059d3dac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/maxeler/maxpower/pulls/39/commits","review_comments_url":"https://api.github.com/repos/maxeler/maxpower/pulls/39/comments","review_comment_url":"https://api.github.com/repos/maxeler/maxpower/pulls/comments{/number}","comments_url":"https://api.github.com/repos/maxeler/maxpower/issues/39/comments","statuses_url":"https://api.github.com/repos/maxeler/maxpower/statuses/ff7eff126596ce0a24686a5d30814ccc61acd8ad","head":{"label":"maxeler:FFT","ref":"FFT","sha":"ff7eff126596ce0a24686a5d30814ccc61acd8ad","user":{"login":"maxeler","id":10088478,"avatar_url":"https://avatars.githubusercontent.com/u/10088478?v=3","gravatar_id":"","url":"https://api.github.com/users/maxeler","html_url":"https://github.com/maxeler","followers_url":"https://api.github.com/users/maxeler/followers","following_url":"https://api.github.com/users/maxeler/following{/other_user}","gists_url":"https://api.github.com/users/maxeler/gists{/gist_id}","starred_url":"https://api.github.com/users/maxeler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxeler/subscriptions","organizations_url":"https://api.github.com/users/maxeler/orgs","repos_url":"https://api.github.com/users/maxeler/repos","events_url":"https://api.github.com/users/maxeler/events{/privacy}","received_events_url":"https://api.github.com/users/maxeler/received_events","type":"Organization","site_admin":false},"repo":{"id":27921920,"name":"maxpower","full_name":"maxeler/maxpower","owner":{"login":"maxeler","id":10088478,"avatar_url":"https://avatars.githubusercontent.com/u/10088478?v=3","gravatar_id":"","url":"https://api.github.com/users/maxeler","html_url":"https://github.com/maxeler","followers_url":"https://api.github.com/users/maxeler/followers","following_url":"https://api.github.com/users/maxeler/following{/other_user}","gists_url":"https://api.github.com/users/maxeler/gists{/gist_id}","starred_url":"https://api.github.com/users/maxeler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxeler/subscriptions","organizations_url":"https://api.github.com/users/maxeler/orgs","repos_url":"https://api.github.com/users/maxeler/repos","events_url":"https://api.github.com/users/maxeler/events{/privacy}","received_events_url":"https://api.github.com/users/maxeler/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/maxeler/maxpower","description":"Maxeler standard library","fork":false,"url":"https://api.github.com/repos/maxeler/maxpower","forks_url":"https://api.github.com/repos/maxeler/maxpower/forks","keys_url":"https://api.github.com/repos/maxeler/maxpower/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maxeler/maxpower/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maxeler/maxpower/teams","hooks_url":"https://api.github.com/repos/maxeler/maxpower/hooks","issue_events_url":"https://api.github.com/repos/maxeler/maxpower/issues/events{/number}","events_url":"https://api.github.com/repos/maxeler/maxpower/events","assignees_url":"https://api.github.com/repos/maxeler/maxpower/assignees{/user}","branches_url":"https://api.github.com/repos/maxeler/maxpower/branches{/branch}","tags_url":"https://api.github.com/repos/maxeler/maxpower/tags","blobs_url":"https://api.github.com/repos/maxeler/maxpower/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maxeler/maxpower/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maxeler/maxpower/git/refs{/sha}","trees_url":"https://api.github.com/repos/maxeler/maxpower/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maxeler/maxpower/statuses/{sha}","languages_url":"https://api.github.com/repos/maxeler/maxpower/languages","stargazers_url":"https://api.github.com/repos/maxeler/maxpower/stargazers","contributors_url":"https://api.github.com/repos/maxeler/maxpower/contributors","subscribers_url":"https://api.github.com/repos/maxeler/maxpower/subscribers","subscription_url":"https://api.github.com/repos/maxeler/maxpower/subscription","commits_url":"https://api.github.com/repos/maxeler/maxpower/commits{/sha}","git_commits_url":"https://api.github.com/repos/maxeler/maxpower/git/commits{/sha}","comments_url":"https://api.github.com/repos/maxeler/maxpower/comments{/number}","issue_comment_url":"https://api.github.com/repos/maxeler/maxpower/issues/comments{/number}","contents_url":"https://api.github.com/repos/maxeler/maxpower/contents/{+path}","compare_url":"https://api.github.com/repos/maxeler/maxpower/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maxeler/maxpower/merges","archive_url":"https://api.github.com/repos/maxeler/maxpower/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maxeler/maxpower/downloads","issues_url":"https://api.github.com/repos/maxeler/maxpower/issues{/number}","pulls_url":"https://api.github.com/repos/maxeler/maxpower/pulls{/number}","milestones_url":"https://api.github.com/repos/maxeler/maxpower/milestones{/number}","notifications_url":"https://api.github.com/repos/maxeler/maxpower/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maxeler/maxpower/labels{/name}","releases_url":"https://api.github.com/repos/maxeler/maxpower/releases{/id}","created_at":"2014-12-12T13:40:35Z","updated_at":"2015-10-13T09:44:13Z","pushed_at":"2015-11-30T11:01:01Z","git_url":"git://github.com/maxeler/maxpower.git","ssh_url":"git@github.com:maxeler/maxpower.git","clone_url":"https://github.com/maxeler/maxpower.git","svn_url":"https://github.com/maxeler/maxpower","homepage":null,"size":2787,"stargazers_count":7,"watchers_count":7,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":13,"forks":7,"open_issues":13,"watchers":7,"default_branch":"master"}},"base":{"label":"maxeler:master","ref":"master","sha":"8e0802cab290747708806142d86ecead0af3d768","user":{"login":"maxeler","id":10088478,"avatar_url":"https://avatars.githubusercontent.com/u/10088478?v=3","gravatar_id":"","url":"https://api.github.com/users/maxeler","html_url":"https://github.com/maxeler","followers_url":"https://api.github.com/users/maxeler/followers","following_url":"https://api.github.com/users/maxeler/following{/other_user}","gists_url":"https://api.github.com/users/maxeler/gists{/gist_id}","starred_url":"https://api.github.com/users/maxeler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxeler/subscriptions","organizations_url":"https://api.github.com/users/maxeler/orgs","repos_url":"https://api.github.com/users/maxeler/repos","events_url":"https://api.github.com/users/maxeler/events{/privacy}","received_events_url":"https://api.github.com/users/maxeler/received_events","type":"Organization","site_admin":false},"repo":{"id":27921920,"name":"maxpower","full_name":"maxeler/maxpower","owner":{"login":"maxeler","id":10088478,"avatar_url":"https://avatars.githubusercontent.com/u/10088478?v=3","gravatar_id":"","url":"https://api.github.com/users/maxeler","html_url":"https://github.com/maxeler","followers_url":"https://api.github.com/users/maxeler/followers","following_url":"https://api.github.com/users/maxeler/following{/other_user}","gists_url":"https://api.github.com/users/maxeler/gists{/gist_id}","starred_url":"https://api.github.com/users/maxeler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxeler/subscriptions","organizations_url":"https://api.github.com/users/maxeler/orgs","repos_url":"https://api.github.com/users/maxeler/repos","events_url":"https://api.github.com/users/maxeler/events{/privacy}","received_events_url":"https://api.github.com/users/maxeler/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/maxeler/maxpower","description":"Maxeler standard library","fork":false,"url":"https://api.github.com/repos/maxeler/maxpower","forks_url":"https://api.github.com/repos/maxeler/maxpower/forks","keys_url":"https://api.github.com/repos/maxeler/maxpower/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maxeler/maxpower/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maxeler/maxpower/teams","hooks_url":"https://api.github.com/repos/maxeler/maxpower/hooks","issue_events_url":"https://api.github.com/repos/maxeler/maxpower/issues/events{/number}","events_url":"https://api.github.com/repos/maxeler/maxpower/events","assignees_url":"https://api.github.com/repos/maxeler/maxpower/assignees{/user}","branches_url":"https://api.github.com/repos/maxeler/maxpower/branches{/branch}","tags_url":"https://api.github.com/repos/maxeler/maxpower/tags","blobs_url":"https://api.github.com/repos/maxeler/maxpower/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maxeler/maxpower/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maxeler/maxpower/git/refs{/sha}","trees_url":"https://api.github.com/repos/maxeler/maxpower/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maxeler/maxpower/statuses/{sha}","languages_url":"https://api.github.com/repos/maxeler/maxpower/languages","stargazers_url":"https://api.github.com/repos/maxeler/maxpower/stargazers","contributors_url":"https://api.github.com/repos/maxeler/maxpower/contributors","subscribers_url":"https://api.github.com/repos/maxeler/maxpower/subscribers","subscription_url":"https://api.github.com/repos/maxeler/maxpower/subscription","commits_url":"https://api.github.com/repos/maxeler/maxpower/commits{/sha}","git_commits_url":"https://api.github.com/repos/maxeler/maxpower/git/commits{/sha}","comments_url":"https://api.github.com/repos/maxeler/maxpower/comments{/number}","issue_comment_url":"https://api.github.com/repos/maxeler/maxpower/issues/comments{/number}","contents_url":"https://api.github.com/repos/maxeler/maxpower/contents/{+path}","compare_url":"https://api.github.com/repos/maxeler/maxpower/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maxeler/maxpower/merges","archive_url":"https://api.github.com/repos/maxeler/maxpower/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maxeler/maxpower/downloads","issues_url":"https://api.github.com/repos/maxeler/maxpower/issues{/number}","pulls_url":"https://api.github.com/repos/maxeler/maxpower/pulls{/number}","milestones_url":"https://api.github.com/repos/maxeler/maxpower/milestones{/number}","notifications_url":"https://api.github.com/repos/maxeler/maxpower/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maxeler/maxpower/labels{/name}","releases_url":"https://api.github.com/repos/maxeler/maxpower/releases{/id}","created_at":"2014-12-12T13:40:35Z","updated_at":"2015-10-13T09:44:13Z","pushed_at":"2015-11-30T11:01:01Z","git_url":"git://github.com/maxeler/maxpower.git","ssh_url":"git@github.com:maxeler/maxpower.git","clone_url":"https://github.com/maxeler/maxpower.git","svn_url":"https://github.com/maxeler/maxpower","homepage":null,"size":2787,"stargazers_count":7,"watchers_count":7,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":13,"forks":7,"open_issues":13,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/maxeler/maxpower/pulls/39"},"html":{"href":"https://github.com/maxeler/maxpower/pull/39"},"issue":{"href":"https://api.github.com/repos/maxeler/maxpower/issues/39"},"comments":{"href":"https://api.github.com/repos/maxeler/maxpower/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/maxeler/maxpower/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/maxeler/maxpower/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/maxeler/maxpower/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/maxeler/maxpower/statuses/ff7eff126596ce0a24686a5d30814ccc61acd8ad"}}}}