Skip to content

Commit

Permalink
Update test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
afasolino authored May 30, 2024
1 parent 69777ce commit abb90c2
Showing 1 changed file with 92 additions and 6 deletions.
98 changes: 92 additions & 6 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ async def test_project(dut):
dut.rst_n.value = 1

dut._log.info("Test project behavior")

#########################################
# write in the input buffer
########################################
# Set 7:0 bits to 20
dut.ui_in.value = 20
# check alu ready == 1
Expand Down Expand Up @@ -53,8 +56,6 @@ async def test_project(dut):
dut.uio_in.value = 0

await ClockCycles(dut.clk, 4)

#########################################
# Set 23:15 bits to 30
dut.ui_in.value = 30
# check alu ready == 1
Expand Down Expand Up @@ -83,7 +84,8 @@ async def test_project(dut):
dut.uio_in.value = 0

#########################################

# read output buffer with input values
########################################

# check if the input data is correctly written in the input buffer and if it can be read from the output buffer
await ClockCycles(dut.clk, 8)
Expand All @@ -98,7 +100,7 @@ async def test_project(dut):
await ClockCycles(dut.clk, 8)

assert dut.uio_out.value == 8
dut._log.info("The result is: %d" % dut.uo_out.value)
#dut._log.info("The result is: %d" % dut.uo_out.value)
assert dut.uo_out.value == 0

dut.uio_in.value = 4
Expand All @@ -107,15 +109,99 @@ async def test_project(dut):
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

dut._log.info("The result is: %d" % dut.uo_out.value)
#dut._log.info("The result is: %d" % dut.uo_out.value)
assert dut.uo_out.value == 30

dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)

dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)
dut._log.info("The result is: %d" % dut.uo_out.value)
#dut._log.info("The result is: %d" % dut.uo_out.value)

assert dut.uo_out.value == 0
dut.uio_in.value = 4

##############################################################################################################
# read the concatenation of sign, regime decimal value and exponent for the converted data, namely ap and bp, on 8 bit each one
##############################################################################################################

await ClockCycles(dut.clk, 8)

assert dut.uio_out.value == 8
assert dut.uo_out.value == 21
dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)
assert dut.uio_out.value == 0
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

assert dut.uio_out.value == 8
assert dut.uo_out.value == 21
dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)
assert dut.uio_out.value == 0
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

##############################################################################################################
# read the mantissas of ap and bp, on 16 bit each one
##############################################################################################################

# mantissa ap part 1
assert dut.uio_out.value == 8
assert dut.uo_out.value == 0
dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)
assert dut.uio_out.value == 0
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

# mantissa ap part 2
assert dut.uio_out.value == 8
assert dut.uo_out.value == 4
dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)
assert dut.uio_out.value == 0
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

# mantissa bp part 1
assert dut.uio_out.value == 8
assert dut.uo_out.value == 0
dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)
assert dut.uio_out.value == 0
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

# mantissa bp part 2
assert dut.uio_out.value == 8
assert dut.uo_out.value == 14
dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)
assert dut.uio_out.value == 0
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

##############################################################################################################
# read the result of the posit addition, on 16 bits
##############################################################################################################

# result part 1
assert dut.uio_out.value == 8
assert dut.uo_out.value == 144
dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)
assert dut.uio_out.value == 0
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

# result part 1
assert dut.uio_out.value == 8
assert dut.uo_out.value == 2
dut.uio_in.value = 4
await ClockCycles(dut.clk, 4)
assert dut.uio_out.value == 0
dut.uio_in.value = 0
await ClockCycles(dut.clk, 8)

0 comments on commit abb90c2

Please sign in to comment.