-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dependencies] add berkeley-hardfloat to source tree
- Loading branch information
Showing
138 changed files
with
7,232 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ coverage.dat | |
build | ||
/result* | ||
*/result* | ||
/dependencies | ||
__pycache__ | ||
/testrun | ||
.direnv | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
fma-test: | ||
name: Use testfloat to test hardfloat | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
chisel: ["3.5.6", "3.6.0", "5.0.0"] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'true' | ||
- uses: cachix/install-nix-action@v19 | ||
with: | ||
install_url: https://releases.nixos.org/nix/nix-2.13.3/install | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
- name: run test | ||
run: | | ||
nix --experimental-features 'nix-command flakes' develop -c mill -j 0 'hardfloatdut[${{ matrix.chisel }}].test' | ||
sbt-test: | ||
name: Use testfloat to test hardfloat (with SBT) | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
java: 8 | ||
- os: ubuntu-latest | ||
java: 11 | ||
- os: ubuntu-latest | ||
java: 17 | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: temurin | ||
java-version: ${{ matrix.java }} | ||
cache: sbt | ||
- name: Install Verilator | ||
run: sudo apt-get install -y verilator gcc | ||
- name: Build and test | ||
shell: bash | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
project/target | ||
target | ||
test_run_dir | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "berkeley-softfloat-3"] | ||
path = berkeley-softfloat-3 | ||
url = https://github.com/ucb-bar/berkeley-softfloat-3.git | ||
[submodule "berkeley-testfloat-3"] | ||
path = berkeley-testfloat-3 | ||
url = https://github.com/ucb-bar/berkeley-testfloat-3.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Copyright (c) 2010-2015, The Regents of the University of California | ||
(Regents). All Rights Reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the Regents nor the | ||
names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, | ||
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING | ||
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS | ||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED | ||
HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE | ||
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
default: test | ||
|
||
berkeley-softfloat-3/.git: | ||
git submodule update --init berkeley-softfloat-3 | ||
|
||
berkeley-testfloat-3/.git: | ||
git submodule update --init berkeley-testfloat-3 | ||
|
||
berkeley-softfloat-3/build/Linux-x86_64-GCC/softfloat.a: berkeley-softfloat-3/.git | ||
$(MAKE) -C berkeley-softfloat-3/build/Linux-x86_64-GCC SPECIALIZE_TYPE=RISCV | ||
|
||
berkeley-testfloat-3/build/Linux-x86_64-GCC/testfloat_gen: berkeley-testfloat-3/.git \ | ||
berkeley-softfloat-3/build/Linux-x86_64-GCC/softfloat.a | ||
$(MAKE) -C berkeley-testfloat-3/build/Linux-x86_64-GCC SPECIALIZE_TYPE=RISCV | ||
|
||
ifneq (,$(shell which testfloat_gen 2> /dev/null)) | ||
TESTFLOAT_GEN: ; | ||
else | ||
PATH := $(PATH):$(PWD)/berkeley-testfloat-3/build/Linux-x86_64-GCC/ | ||
TESTFLOAT_GEN: berkeley-testfloat-3/build/Linux-x86_64-GCC/testfloat_gen | ||
endif | ||
|
||
test: TESTFLOAT_GEN | ||
sbt test | ||
|
||
clean: | ||
git clean -fdx | ||
git submodule foreach git clean -fdx | ||
|
||
.PHONY: test clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Berkeley Hardware Floating-Point Units | ||
====================================== | ||
|
||
This repository contains hardware floating-point units written in Chisel. | ||
This library contains parameterized floating-point units for fused multiply-add | ||
operations, conversions between integer and floating-point numbers, and | ||
conversions between floating-point conversions with different precision. | ||
|
||
**WARNING**: | ||
These units are works in progress. They may not be yet completely free of | ||
bugs, nor are they fully optimized. | ||
|
||
|
||
Recoded Format | ||
-------------- | ||
|
||
The floating-point units in this repository work on an internal recoded format | ||
(exponent has an additional bit) to handle subnormal numbers more efficiently | ||
in a microprocessor. A more detailed explanation will come soon, but in the | ||
mean time here are some example mappings for single-precision numbers. | ||
|
||
IEEE format Recoded format | ||
---------------------------------- ----------------------------------- | ||
s 00000000 00000000000000000000000 s 000------ 00000000000000000000000 | ||
s 00000000 00000000000000000000001 s 001101011 00000000000000000000000 | ||
s 00000000 0000000000000000000001f s 001101100 f0000000000000000000000 | ||
s 00000000 000000000000000000001ff s 001101101 ff000000000000000000000 | ||
... ... ... ... | ||
s 00000000 001ffffffffffffffffffff s 001111111 ffffffffffffffffffff000 | ||
s 00000000 01fffffffffffffffffffff s 010000000 fffffffffffffffffffff00 | ||
s 00000000 1ffffffffffffffffffffff s 010000001 ffffffffffffffffffffff0 | ||
s 00000001 fffffffffffffffffffffff s 010000010 fffffffffffffffffffffff | ||
s 00000010 fffffffffffffffffffffff s 010000011 fffffffffffffffffffffff | ||
... ... ... ... | ||
s 11111101 fffffffffffffffffffffff s 101111110 fffffffffffffffffffffff | ||
s 11111110 fffffffffffffffffffffff s 101111111 fffffffffffffffffffffff | ||
s 11111111 00000000000000000000000 s 110------ ----------------------- | ||
s 11111111 fffffffffffffffffffffff s 111------ fffffffffffffffffffffff | ||
|
||
|
||
Unit-Testing | ||
------------ | ||
|
||
To unit-test these floating-point units, you need the berkeley-testfloat-3 | ||
package. | ||
|
||
To test floating-point units with the C simulator: | ||
|
||
$ make | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
organization := "edu.berkeley.cs" | ||
|
||
version := "1.5-SNAPSHOT" | ||
|
||
name := "hardfloat" | ||
|
||
scalaVersion := "2.13.10" | ||
|
||
resolvers ++= Seq( | ||
Resolver.sonatypeRepo("snapshots"), | ||
Resolver.sonatypeRepo("releases") | ||
) | ||
|
||
Compile / scalaSource := baseDirectory.value / "hardfloat/src/main/scala" | ||
Test / scalaSource := baseDirectory.value / "hardfloat/tests/src" | ||
Test / resourceDirectory := baseDirectory.value / "hardfloat/tests/resources" | ||
|
||
addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % "3.5.6" cross CrossVersion.full) | ||
libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.5.6" | ||
libraryDependencies ++= Seq("org.scalatest" %% "scalatest" % "3.2.0" % "test") | ||
libraryDependencies += "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4" | ||
Test / testForkedParallel := true | ||
|
||
publishMavenStyle := true | ||
publishArtifact in Test := false | ||
pomIncludeRepository := { x => false } | ||
// Don't add 'scm' elements if we have a git.remoteRepo definition, | ||
// but since we don't (with the removal of ghpages), add them in below. | ||
pomExtra := <url>http://chisel.eecs.berkeley.edu/</url> | ||
<licenses> | ||
<license> | ||
<name>BSD-style</name> | ||
<url>http://www.opensource.org/licenses/bsd-license.php</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
<scm> | ||
<url>https://github.com/ucb-bar/berkeley-hardfloat.git</url> | ||
<connection>scm:git:github.com/ucb-bar/berkeley-hardfloat.git</connection> | ||
</scm> | ||
<developers> | ||
<developer> | ||
<id>jhauser-ucberkeley</id> | ||
<name>John Hauser</name> | ||
</developer> | ||
<developer> | ||
<id>aswaterman</id> | ||
<name>Andrew Waterman</name> | ||
</developer> | ||
<developer> | ||
<id>yunsup</id> | ||
<name>Yunsup Lee</name> | ||
</developer> | ||
</developers> | ||
|
||
publishTo := { | ||
val v = version.value | ||
val nexus = "https://oss.sonatype.org/" | ||
if (v.trim.endsWith("SNAPSHOT")) { | ||
Some("snapshots" at nexus + "content/repositories/snapshots") | ||
} | ||
else { | ||
Some("releases" at nexus + "service/local/staging/deploy/maven2") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import mill._ | ||
import mill.scalalib._ | ||
import mill.scalalib.publish._ | ||
import $file.common | ||
|
||
object v { | ||
val scala = "2.13.10" | ||
val chiselCrossVersions = Map( | ||
"3.5.6" -> (ivy"edu.berkeley.cs::chisel3:3.5.6", ivy"edu.berkeley.cs:::chisel3-plugin:3.5.6"), | ||
"3.6.0" -> (ivy"edu.berkeley.cs::chisel3:3.6.0", ivy"edu.berkeley.cs:::chisel3-plugin:3.6.0"), | ||
"5.0.0" -> (ivy"org.chipsalliance::chisel:5.0.0", ivy"org.chipsalliance:::chisel-plugin:5.0.0"), | ||
) | ||
val scalatest = ivy"org.scalatest::scalatest:3.2.0" | ||
val scalapar = ivy"org.scala-lang.modules::scala-parallel-collections:1.0.4" | ||
} | ||
|
||
object hardfloat extends Cross[Hardfloat](v.chiselCrossVersions.keys.toSeq) | ||
|
||
trait Hardfloat | ||
extends common.HardfloatModule | ||
with HardfloatPublishModule | ||
with Cross.Module[String] { | ||
|
||
override def scalaVersion = T(v.scala) | ||
|
||
override def millSourcePath = os.pwd / "hardfloat" | ||
|
||
def chiselModule = None | ||
|
||
def chiselPluginJar = None | ||
|
||
def chiselIvy = Some(v.chiselCrossVersions(crossValue)._1) | ||
|
||
def chiselPluginIvy = Some(v.chiselCrossVersions(crossValue)._2) | ||
} | ||
|
||
object hardfloatdut extends Cross[HardfloatDut](v.chiselCrossVersions.keys.toSeq) | ||
|
||
trait HardfloatDut | ||
extends common.HardfloatTestModule | ||
with Cross.Module[String] { | ||
|
||
override def scalaVersion = T(v.scala) | ||
|
||
override def millSourcePath = os.pwd / "hardfloat" / "tests" | ||
|
||
def hardfloatModule = hardfloat(crossValue) | ||
|
||
def chiselModule = None | ||
|
||
def chiselPluginJar = None | ||
|
||
def chiselIvy = Some(v.chiselCrossVersions(crossValue)._1) | ||
|
||
def chiselPluginIvy = Some(v.chiselCrossVersions(crossValue)._2) | ||
|
||
def scalatestIvy = v.scalatest | ||
|
||
def scalaparIvy = v.scalapar | ||
} | ||
|
||
|
||
trait HardfloatPublishModule extends PublishModule { | ||
def pomSettings = PomSettings( | ||
description = artifactName(), | ||
organization = "edu.berkeley.cs", | ||
url = "http://chisel.eecs.berkeley.edu", | ||
licenses = Seq(License.`BSD-3-Clause`), | ||
versionControl = VersionControl.github("ucb-bar", "berkeley-hardfloat"), | ||
developers = Seq( | ||
Developer("jhauser-ucberkeley", "John Hauser", "https://www.colorado.edu/faculty/hauser/about/"), | ||
Developer("aswaterman", "Andrew Waterman", "https://aspire.eecs.berkeley.edu/author/waterman/"), | ||
Developer("yunsup", "Yunsup Lee", "https://aspire.eecs.berkeley.edu/author/yunsup/") | ||
) | ||
) | ||
|
||
def publishVersion = "1.5-SNAPSHOT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import mill._ | ||
import mill.scalalib._ | ||
|
||
trait HasChisel | ||
extends ScalaModule { | ||
// Define these for building chisel from source | ||
def chiselModule: Option[ScalaModule] | ||
|
||
override def moduleDeps = super.moduleDeps ++ chiselModule | ||
|
||
def chiselPluginJar: T[Option[PathRef]] | ||
|
||
override def scalacOptions = T(super.scalacOptions() ++ chiselPluginJar().map(path => s"-Xplugin:${path.path}")) | ||
|
||
override def scalacPluginClasspath: T[Agg[PathRef]] = T(super.scalacPluginClasspath() ++ chiselPluginJar()) | ||
|
||
// Define these for building chisel from ivy | ||
def chiselIvy: Option[Dep] | ||
|
||
override def ivyDeps = T(super.ivyDeps() ++ chiselIvy) | ||
|
||
def chiselPluginIvy: Option[Dep] | ||
|
||
override def scalacPluginIvyDeps: T[Agg[Dep]] = T(super.scalacPluginIvyDeps() ++ chiselPluginIvy.map(Agg(_)).getOrElse(Agg.empty[Dep])) | ||
} | ||
|
||
trait HardfloatModule | ||
extends HasChisel | ||
|
||
trait HardfloatTestModule | ||
extends TestModule | ||
with HasChisel | ||
with TestModule.ScalaTest { | ||
|
||
def hardfloatModule: HardfloatModule | ||
|
||
def chiselModule = hardfloatModule.chiselModule | ||
|
||
def chiselPluginJar: T[Option[PathRef]] = T(hardfloatModule.chiselPluginJar()) | ||
|
||
def chiselIvy: Option[Dep] = hardfloatModule.chiselIvy | ||
|
||
def chiselPluginIvy: Option[Dep] = hardfloatModule.chiselPluginIvy | ||
|
||
def scalatestIvy: Dep | ||
|
||
def scalaparIvy: Dep | ||
|
||
override def moduleDeps = super.moduleDeps ++ Some(hardfloatModule) | ||
|
||
override def defaultCommandName() = "test" | ||
|
||
override def ivyDeps = T( | ||
super.ivyDeps() ++ Agg( | ||
scalatestIvy, | ||
scalaparIvy | ||
) | ||
) | ||
} |
Oops, something went wrong.