{"action":"created","comment":{"url":"https://api.github.com/repos/ucb-bar/chisel3/pulls/comments/109557298","pull_request_review_id":30666626,"id":109557298,"diff_hunk":"@@ -48,18 +52,68 @@ private[chisel3] object SeqUtils {\n   }\n \n   /** Returns the data value corresponding to the lone true predicate.\n+    * This is elaborated to firrtl using a structure that should be optimized into and and/or tree.\n     *\n     * @note assumes exactly one true predicate, results undefined otherwise\n+    *       FixedPoint values or aggregates containing FixedPoint values cause this optimized structure to be lost\n     */\n   def oneHotMux[T <: Data](in: Iterable[(Bool, T)]): T = macro CompileOptionsTransform.inArg\n \n-  def do_oneHotMux[T <: Data](in: Iterable[(Bool, T)])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {\n+  //scalastyle:off method.length cyclomatic.complexity\n+  def do_oneHotMux[T <: Data](in: Iterable[(Bool, T)])\n+                             (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): T = {\n     if (in.tail.isEmpty) {\n       in.head._2\n-    } else {\n-      val masked = for ((s, i) <- in) yield Mux(s, i.asUInt, 0.U)\n-      val output = cloneSupertype(in.toSeq map {_._2}, \"oneHotMux\")\n-      output.fromBits(masked.reduceLeft(_|_))\n+    }\n+    else {\n+      val output = cloneSupertype(in.toSeq map { _._2}, \"oneHotMux\")\n+\n+      in.head._2 match {\n+        case _: SInt =>\n+          // SInt's have to be managed carefully so sign extension works\n+\n+          val sInts: Iterable[(Bool, SInt)] = in.collect { case (s: Bool, f: SInt) =>\n+            (s, f.asTypeOf(output).asInstanceOf[SInt])\n+          }\n+\n+          val masked = for ((s, i) <- sInts) yield Mux(s, i, 0.S)\n+\n+          output.fromBits(masked.reduceLeft(_ | _))\n+\n+        case _: FixedPoint =>\n+          // FixedPoint doesn't support *or* so use Muxes\n+          val output = cloneSupertype(in.toSeq map { _._2 }, \"oneHotMux\")\n+          val fixedPoints = in.collect { case (s: Bool, f: FixedPoint) => (s, f) }\n+\n+          def makeMux(inputs: List[(Bool, FixedPoint)]): FixedPoint = {\n+            inputs match {\n+              case Nil => 0.U.asTypeOf(output).asInstanceOf[FixedPoint]\n+              case (select, value) :: tail =>\n+                Mux(select, value, makeMux(tail))\n+            }\n+          }\n+\n+          makeMux(fixedPoints.toList).asTypeOf(output)\n+\n+        case aggregate: Aggregate =>\n+          val allSameType = in.forall { case (_, element) => in.head._2.typeEquivalent(element) }","path":"chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala","position":78,"original_position":78,"commit_id":"522e100920662ef38ce79e379333aadb6ccc52cb","original_commit_id":"522e100920662ef38ce79e379333aadb6ccc52cb","user":{"login":"ducky64","id":1069863,"avatar_url":"https://avatars3.githubusercontent.com/u/1069863?v=3","gravatar_id":"","url":"https://api.github.com/users/ducky64","html_url":"https://github.com/ducky64","followers_url":"https://api.github.com/users/ducky64/followers","following_url":"https://api.github.com/users/ducky64/following{/other_user}","gists_url":"https://api.github.com/users/ducky64/gists{/gist_id}","starred_url":"https://api.github.com/users/ducky64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ducky64/subscriptions","organizations_url":"https://api.github.com/users/ducky64/orgs","repos_url":"https://api.github.com/users/ducky64/repos","events_url":"https://api.github.com/users/ducky64/events{/privacy}","received_events_url":"https://api.github.com/users/ducky64/received_events","type":"User","site_admin":false},"body":"isn't this already checked by cloneSupertype?","created_at":"2017-04-04T00:49:36Z","updated_at":"2017-04-04T00:59:27Z","html_url":"https://github.com/ucb-bar/chisel3/pull/573#discussion_r109557298","pull_request_url":"https://api.github.com/repos/ucb-bar/chisel3/pulls/573","_links":{"self":{"href":"https://api.github.com/repos/ucb-bar/chisel3/pulls/comments/109557298"},"html":{"href":"https://github.com/ucb-bar/chisel3/pull/573#discussion_r109557298"},"pull_request":{"href":"https://api.github.com/repos/ucb-bar/chisel3/pulls/573"}}},"pull_request":{"url":"https://api.github.com/repos/ucb-bar/chisel3/pulls/573","id":114046660,"html_url":"https://github.com/ucb-bar/chisel3/pull/573","diff_url":"https://github.com/ucb-bar/chisel3/pull/573.diff","patch_url":"https://github.com/ucb-bar/chisel3/pull/573.patch","issue_url":"https://api.github.com/repos/ucb-bar/chisel3/issues/573","number":573,"state":"open","locked":false,"title":"Fix one hot mux","user":{"login":"chick","id":923223,"avatar_url":"https://avatars1.githubusercontent.com/u/923223?v=3","gravatar_id":"","url":"https://api.github.com/users/chick","html_url":"https://github.com/chick","followers_url":"https://api.github.com/users/chick/followers","following_url":"https://api.github.com/users/chick/following{/other_user}","gists_url":"https://api.github.com/users/chick/gists{/gist_id}","starred_url":"https://api.github.com/users/chick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chick/subscriptions","organizations_url":"https://api.github.com/users/chick/orgs","repos_url":"https://api.github.com/users/chick/repos","events_url":"https://api.github.com/users/chick/events{/privacy}","received_events_url":"https://api.github.com/users/chick/received_events","type":"User","site_admin":false},"body":"Answers some of Angie's problems for #558 Mux1H\r\n- Implements FixedPoint as MuxTree, this is not optimized\r\n- catches some cases of inferred with aggregates not working\r\n- adds tests that illustrate a number of situations","created_at":"2017-04-03T23:54:51Z","updated_at":"2017-04-04T00:59:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"606aefb9508eebe433af26ca4ffc9fa634ee3c14","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ucb-bar/chisel3/pulls/573/commits","review_comments_url":"https://api.github.com/repos/ucb-bar/chisel3/pulls/573/comments","review_comment_url":"https://api.github.com/repos/ucb-bar/chisel3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ucb-bar/chisel3/issues/573/comments","statuses_url":"https://api.github.com/repos/ucb-bar/chisel3/statuses/522e100920662ef38ce79e379333aadb6ccc52cb","head":{"label":"ucb-bar:fix-one-hot-mux","ref":"fix-one-hot-mux","sha":"522e100920662ef38ce79e379333aadb6ccc52cb","user":{"login":"ucb-bar","id":998197,"avatar_url":"https://avatars0.githubusercontent.com/u/998197?v=3","gravatar_id":"","url":"https://api.github.com/users/ucb-bar","html_url":"https://github.com/ucb-bar","followers_url":"https://api.github.com/users/ucb-bar/followers","following_url":"https://api.github.com/users/ucb-bar/following{/other_user}","gists_url":"https://api.github.com/users/ucb-bar/gists{/gist_id}","starred_url":"https://api.github.com/users/ucb-bar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ucb-bar/subscriptions","organizations_url":"https://api.github.com/users/ucb-bar/orgs","repos_url":"https://api.github.com/users/ucb-bar/repos","events_url":"https://api.github.com/users/ucb-bar/events{/privacy}","received_events_url":"https://api.github.com/users/ucb-bar/received_events","type":"Organization","site_admin":false},"repo":{"id":34695562,"name":"chisel3","full_name":"ucb-bar/chisel3","owner":{"login":"ucb-bar","id":998197,"avatar_url":"https://avatars0.githubusercontent.com/u/998197?v=3","gravatar_id":"","url":"https://api.github.com/users/ucb-bar","html_url":"https://github.com/ucb-bar","followers_url":"https://api.github.com/users/ucb-bar/followers","following_url":"https://api.github.com/users/ucb-bar/following{/other_user}","gists_url":"https://api.github.com/users/ucb-bar/gists{/gist_id}","starred_url":"https://api.github.com/users/ucb-bar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ucb-bar/subscriptions","organizations_url":"https://api.github.com/users/ucb-bar/orgs","repos_url":"https://api.github.com/users/ucb-bar/repos","events_url":"https://api.github.com/users/ucb-bar/events{/privacy}","received_events_url":"https://api.github.com/users/ucb-bar/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ucb-bar/chisel3","description":"Chisel 3","fork":false,"url":"https://api.github.com/repos/ucb-bar/chisel3","forks_url":"https://api.github.com/repos/ucb-bar/chisel3/forks","keys_url":"https://api.github.com/repos/ucb-bar/chisel3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ucb-bar/chisel3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ucb-bar/chisel3/teams","hooks_url":"https://api.github.com/repos/ucb-bar/chisel3/hooks","issue_events_url":"https://api.github.com/repos/ucb-bar/chisel3/issues/events{/number}","events_url":"https://api.github.com/repos/ucb-bar/chisel3/events","assignees_url":"https://api.github.com/repos/ucb-bar/chisel3/assignees{/user}","branches_url":"https://api.github.com/repos/ucb-bar/chisel3/branches{/branch}","tags_url":"https://api.github.com/repos/ucb-bar/chisel3/tags","blobs_url":"https://api.github.com/repos/ucb-bar/chisel3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ucb-bar/chisel3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ucb-bar/chisel3/git/refs{/sha}","trees_url":"https://api.github.com/repos/ucb-bar/chisel3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ucb-bar/chisel3/statuses/{sha}","languages_url":"https://api.github.com/repos/ucb-bar/chisel3/languages","stargazers_url":"https://api.github.com/repos/ucb-bar/chisel3/stargazers","contributors_url":"https://api.github.com/repos/ucb-bar/chisel3/contributors","subscribers_url":"https://api.github.com/repos/ucb-bar/chisel3/subscribers","subscription_url":"https://api.github.com/repos/ucb-bar/chisel3/subscription","commits_url":"https://api.github.com/repos/ucb-bar/chisel3/commits{/sha}","git_commits_url":"https://api.github.com/repos/ucb-bar/chisel3/git/commits{/sha}","comments_url":"https://api.github.com/repos/ucb-bar/chisel3/comments{/number}","issue_comment_url":"https://api.github.com/repos/ucb-bar/chisel3/issues/comments{/number}","contents_url":"https://api.github.com/repos/ucb-bar/chisel3/contents/{+path}","compare_url":"https://api.github.com/repos/ucb-bar/chisel3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ucb-bar/chisel3/merges","archive_url":"https://api.github.com/repos/ucb-bar/chisel3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ucb-bar/chisel3/downloads","issues_url":"https://api.github.com/repos/ucb-bar/chisel3/issues{/number}","pulls_url":"https://api.github.com/repos/ucb-bar/chisel3/pulls{/number}","milestones_url":"https://api.github.com/repos/ucb-bar/chisel3/milestones{/number}","notifications_url":"https://api.github.com/repos/ucb-bar/chisel3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ucb-bar/chisel3/labels{/name}","releases_url":"https://api.github.com/repos/ucb-bar/chisel3/releases{/id}","deployments_url":"https://api.github.com/repos/ucb-bar/chisel3/deployments","created_at":"2015-04-27T22:55:56Z","updated_at":"2017-04-04T00:24:54Z","pushed_at":"2017-04-03T23:54:59Z","git_url":"git://github.com/ucb-bar/chisel3.git","ssh_url":"git@github.com:ucb-bar/chisel3.git","clone_url":"https://github.com/ucb-bar/chisel3.git","svn_url":"https://github.com/ucb-bar/chisel3","homepage":"https://chisel.eecs.berkeley.edu/","size":1871,"stargazers_count":96,"watchers_count":96,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":88,"forks":40,"open_issues":88,"watchers":96,"default_branch":"master"}},"base":{"label":"ucb-bar:master","ref":"master","sha":"bc05b7dadbd875c5a1ffb1448c36fcdb429386ab","user":{"login":"ucb-bar","id":998197,"avatar_url":"https://avatars0.githubusercontent.com/u/998197?v=3","gravatar_id":"","url":"https://api.github.com/users/ucb-bar","html_url":"https://github.com/ucb-bar","followers_url":"https://api.github.com/users/ucb-bar/followers","following_url":"https://api.github.com/users/ucb-bar/following{/other_user}","gists_url":"https://api.github.com/users/ucb-bar/gists{/gist_id}","starred_url":"https://api.github.com/users/ucb-bar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ucb-bar/subscriptions","organizations_url":"https://api.github.com/users/ucb-bar/orgs","repos_url":"https://api.github.com/users/ucb-bar/repos","events_url":"https://api.github.com/users/ucb-bar/events{/privacy}","received_events_url":"https://api.github.com/users/ucb-bar/received_events","type":"Organization","site_admin":false},"repo":{"id":34695562,"name":"chisel3","full_name":"ucb-bar/chisel3","owner":{"login":"ucb-bar","id":998197,"avatar_url":"https://avatars0.githubusercontent.com/u/998197?v=3","gravatar_id":"","url":"https://api.github.com/users/ucb-bar","html_url":"https://github.com/ucb-bar","followers_url":"https://api.github.com/users/ucb-bar/followers","following_url":"https://api.github.com/users/ucb-bar/following{/other_user}","gists_url":"https://api.github.com/users/ucb-bar/gists{/gist_id}","starred_url":"https://api.github.com/users/ucb-bar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ucb-bar/subscriptions","organizations_url":"https://api.github.com/users/ucb-bar/orgs","repos_url":"https://api.github.com/users/ucb-bar/repos","events_url":"https://api.github.com/users/ucb-bar/events{/privacy}","received_events_url":"https://api.github.com/users/ucb-bar/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ucb-bar/chisel3","description":"Chisel 3","fork":false,"url":"https://api.github.com/repos/ucb-bar/chisel3","forks_url":"https://api.github.com/repos/ucb-bar/chisel3/forks","keys_url":"https://api.github.com/repos/ucb-bar/chisel3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ucb-bar/chisel3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ucb-bar/chisel3/teams","hooks_url":"https://api.github.com/repos/ucb-bar/chisel3/hooks","issue_events_url":"https://api.github.com/repos/ucb-bar/chisel3/issues/events{/number}","events_url":"https://api.github.com/repos/ucb-bar/chisel3/events","assignees_url":"https://api.github.com/repos/ucb-bar/chisel3/assignees{/user}","branches_url":"https://api.github.com/repos/ucb-bar/chisel3/branches{/branch}","tags_url":"https://api.github.com/repos/ucb-bar/chisel3/tags","blobs_url":"https://api.github.com/repos/ucb-bar/chisel3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ucb-bar/chisel3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ucb-bar/chisel3/git/refs{/sha}","trees_url":"https://api.github.com/repos/ucb-bar/chisel3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ucb-bar/chisel3/statuses/{sha}","languages_url":"https://api.github.com/repos/ucb-bar/chisel3/languages","stargazers_url":"https://api.github.com/repos/ucb-bar/chisel3/stargazers","contributors_url":"https://api.github.com/repos/ucb-bar/chisel3/contributors","subscribers_url":"https://api.github.com/repos/ucb-bar/chisel3/subscribers","subscription_url":"https://api.github.com/repos/ucb-bar/chisel3/subscription","commits_url":"https://api.github.com/repos/ucb-bar/chisel3/commits{/sha}","git_commits_url":"https://api.github.com/repos/ucb-bar/chisel3/git/commits{/sha}","comments_url":"https://api.github.com/repos/ucb-bar/chisel3/comments{/number}","issue_comment_url":"https://api.github.com/repos/ucb-bar/chisel3/issues/comments{/number}","contents_url":"https://api.github.com/repos/ucb-bar/chisel3/contents/{+path}","compare_url":"https://api.github.com/repos/ucb-bar/chisel3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ucb-bar/chisel3/merges","archive_url":"https://api.github.com/repos/ucb-bar/chisel3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ucb-bar/chisel3/downloads","issues_url":"https://api.github.com/repos/ucb-bar/chisel3/issues{/number}","pulls_url":"https://api.github.com/repos/ucb-bar/chisel3/pulls{/number}","milestones_url":"https://api.github.com/repos/ucb-bar/chisel3/milestones{/number}","notifications_url":"https://api.github.com/repos/ucb-bar/chisel3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ucb-bar/chisel3/labels{/name}","releases_url":"https://api.github.com/repos/ucb-bar/chisel3/releases{/id}","deployments_url":"https://api.github.com/repos/ucb-bar/chisel3/deployments","created_at":"2015-04-27T22:55:56Z","updated_at":"2017-04-04T00:24:54Z","pushed_at":"2017-04-03T23:54:59Z","git_url":"git://github.com/ucb-bar/chisel3.git","ssh_url":"git@github.com:ucb-bar/chisel3.git","clone_url":"https://github.com/ucb-bar/chisel3.git","svn_url":"https://github.com/ucb-bar/chisel3","homepage":"https://chisel.eecs.berkeley.edu/","size":1871,"stargazers_count":96,"watchers_count":96,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":88,"forks":40,"open_issues":88,"watchers":96,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ucb-bar/chisel3/pulls/573"},"html":{"href":"https://github.com/ucb-bar/chisel3/pull/573"},"issue":{"href":"https://api.github.com/repos/ucb-bar/chisel3/issues/573"},"comments":{"href":"https://api.github.com/repos/ucb-bar/chisel3/issues/573/comments"},"review_comments":{"href":"https://api.github.com/repos/ucb-bar/chisel3/pulls/573/comments"},"review_comment":{"href":"https://api.github.com/repos/ucb-bar/chisel3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ucb-bar/chisel3/pulls/573/commits"},"statuses":{"href":"https://api.github.com/repos/ucb-bar/chisel3/statuses/522e100920662ef38ce79e379333aadb6ccc52cb"}}}}
{"actor":{"display_login":"ducky64"}}