Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor legacy tests which has been broken by Chisel/FIRRTL x.5. #240

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
remove all legacies, meet the new world.
  • Loading branch information
sequencer committed Jan 11, 2023
commit fc9c70afaf2fe48f08c9015cf977773012be5a29
93 changes: 0 additions & 93 deletions src/main/scala/dsptools/Driver.scala

This file was deleted.

51 changes: 0 additions & 51 deletions src/main/scala/dsptools/dspmath/Factorization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

package dsptools.dspmath

import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

case class RadPow(rad: Int, pow: Int) {
/** `r ^ p` */
def get: Int = BigInt(rad).pow(pow).toInt
Expand Down Expand Up @@ -86,51 +83,3 @@ case class Factorization(supportedRadsUnsorted: Seq[Seq[Int]]) {

}

class FactorizationSpec extends AnyFlatSpec with Matchers {

val testSupportedRads = Seq(Seq(4, 2), Seq(3), Seq(5), Seq(7))

behavior of "Factorization"
it should "properly factorize" in {
case class FactorizationTest(n: Int, pows: Seq[Int], coprimes: Seq[Int])
val tests = Seq(
FactorizationTest(
n = (math.pow(4, 5) * math.pow(2, 1) * math.pow(3, 7)).toInt,
pows = Seq(5, 1, 7),
coprimes = Seq((math.pow(4, 5) * math.pow(2, 1)).toInt, math.pow(3, 7).toInt)
),
FactorizationTest(n = 15, pows = Seq(0, 0, 1, 1), coprimes = Seq(1, 3, 5))
)

tests foreach { case FactorizationTest(n, pows, coprimes) =>
val powsFill = Seq.fill(testSupportedRads.flatten.length - pows.length)(0)
val coprimesFill = Seq.fill(testSupportedRads.length - coprimes.length)(1)
require(
Factorization(testSupportedRads).getPowsFlat(n) == pows ++ powsFill,
"Should factorize to get the right powers -- includes padding."
)
require(
Factorization(testSupportedRads).getCoprimes(n) == coprimes ++ coprimesFill,
"Should factorize into the right coprimes -- includes padding."
)
}
}

it should "properly factorize coprime" in {
case class CoprimeFactorizationTest(n: Int, factorization: Seq[Int], basePrime: Int)
val tests = Seq(
CoprimeFactorizationTest(n = 8, factorization = Seq(4, 2), basePrime = 2),
CoprimeFactorizationTest(n = 16, factorization = Seq(4, 4), basePrime = 2)
)
tests foreach { case CoprimeFactorizationTest(n, factorization, basePrime) =>
require(
Factorization(testSupportedRads).factorizeCoprime(n) == factorization,
"Should factorize coprime properly."
)
require(
Factorization(testSupportedRads).getBasePrime(n) == basePrime,
"Should get the correct base prime."
)
}
}
}
Loading