-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
103 additions
and
50 deletions.
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
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
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
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
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,42 @@ | ||
package division.srt | ||
|
||
import chisel3._ | ||
import chisel3.tester.{ChiselUtestTester, testableClock, testableData} | ||
import utest._ | ||
|
||
object SRT4Test extends TestSuite with ChiselUtestTester{ | ||
def tests: Tests = Tests { | ||
test("SRT4 should pass") { | ||
// parameters | ||
val dividendWidth: Int = 4 | ||
val dividerWidth: Int = 3 | ||
val n: Int = 3 | ||
val dividend: Int = 7 | ||
val divider: Int = 3 | ||
val countr: Int = 2 | ||
val remainder: Int = dividend / divider | ||
val quotient: Int = dividend % divider | ||
//test | ||
testCircuit(new SRT(dividendWidth, dividerWidth, n), | ||
Seq(chiseltest.internal.NoThreadingAnnotation, | ||
chiseltest.simulator.WriteVcdAnnotation)){ | ||
dut: SRT => | ||
dut.clock.setTimeout(0) | ||
dut.input.valid.poke(true.B) | ||
dut.input.bits.dividend.poke(dividend.U) | ||
dut.input.bits.divider.poke(divider.U) | ||
dut.input.bits.counter.poke(countr.U) | ||
var flag = false | ||
for(a <- 1 to 1000) { | ||
dut.clock.step() | ||
if(dut.output.valid.peek().litValue == 1) { | ||
flag = true | ||
utest.assert(dut.output.bits.quotient.peek().litValue == quotient) | ||
utest.assert(dut.output.bits.reminder.peek().litValue == remainder) | ||
} | ||
} | ||
utest.assert(flag) | ||
} | ||
} | ||
} | ||
} |