Just noticed that when get_value is used in conjunction with SInt types, the values are treated as unsigned. An example is shown below, where the value 214 is returned instead of -42. It appears the reason is that the generated testbench code does not attach the signed attribute to signed signals. However, this only ends up impacting get_value, not expect.
test.py
from pathlib import Path
import fault
import magma as m
class dut(m.Circuit):
io = m.IO(
a=m.In(m.SInt[8]),
y=m.Out(m.SInt[8]),
clk=m.ClockIn
)
t = fault.Tester(dut, dut.clk)
t.poke(dut.a, -42)
t.step(2)
y = t.get_value(dut.a)
t.step(2)
t.compile_and_run(
target='system-verilog',
simulator='iverilog',
ext_srcs=[Path('dut.sv').resolve()],
ext_model_file=True
)
print('y', y.value)
dut.sv
module dut (
input signed [7:0] a,
input clk,
output reg signed [7:0] y
);
always @(posedge clk) begin
y <= a;
end
endmodule
Just noticed that when
get_valueis used in conjunction withSInttypes, the values are treated as unsigned. An example is shown below, where the value214is returned instead of-42. It appears the reason is that the generated testbench code does not attach thesignedattribute to signed signals. However, this only ends up impactingget_value, notexpect.test.py
dut.sv