Skip to content

Commit

Permalink
일단 양수양수 덧셈은 가능함
Browse files Browse the repository at this point in the history
  • Loading branch information
js4ngu committed Sep 13, 2024
1 parent 8b149f6 commit 096a72b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/vfrope/ieee754.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class FP32Adder extends Module {
val mantissaSumExtended = Cat(mantissaSum, 0.U(2.W)) // Add two guard bits
val normalizationNeeded = mantissaSumExtended(25) // 24th 비트에서 overflow 확인
val normalizedMantissa = Mux(normalizationNeeded, mantissaSumExtended(24, 2), mantissaSumExtended(23, 1))
val finalExponentNormalized = Mux(normalizationNeeded, finalExponent + 1.U, finalExponent)
val finalExponentNormalized = finalExponent // 지수는 그대로 유지

// Debug: Print normalization-related values
printf(p"\nmantissaSumExtended: $mantissaSumExtended\n")
printf(p"Normalization Needed: $normalizationNeeded\n")
Expand Down
10 changes: 5 additions & 5 deletions src/test/scala/vfrope/ieee754test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class FP32AdderTest extends AnyFlatSpec with ChiselScalatestTester {
dut.io.a.poke(0x3fc00000.U) // 1.5
dut.io.b.poke(0x40100000.U) // 2.25
dut.clock.step()
println(s"expected 40700000 : 0x${dut.io.result.peek().litValue.toString(16)}")
println(s"expected 40700000 : 0x${dut.io.result.peek().litValue.toString(16)}\n\n")

// For negative numbers, use BigInt to handle UInt interpretation correctly
// dut.io.a.poke(BigInt("bfc00000", 16).U) // -1.5
// dut.io.b.poke(0x40100000.U) // 2.25
// dut.clock.step()
// println(s"expected 3f400000 : 0x${dut.io.result.peek().litValue.toString(16)}")
dut.io.a.poke(BigInt("bfc00000", 16).U) // -1.5
dut.io.b.poke(0x40100000.U) // 2.25
dut.clock.step()
println(s"expected 3f400000 : 0x${dut.io.result.peek().litValue.toString(16)}")

// dut.io.a.poke(0x3fc00000.U) // 1.5
// dut.io.b.poke(BigInt("c0100000", 16).U) // -2.25
Expand Down

0 comments on commit 096a72b

Please sign in to comment.