2023-06-27 20:50:45 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -ex
|
2020-12-05 16:26:25 -06:00
|
|
|
|
2023-06-27 20:51:11 -05:00
|
|
|
../../yosys -p 'read_verilog initial_display.v' | awk '/<<<BEGIN>>>/,/<<<END>>>/ {print $0}' >yosys-initial_display.log
|
2020-12-05 16:26:25 -06:00
|
|
|
iverilog -o iverilog-initial_display initial_display.v
|
|
|
|
./iverilog-initial_display >iverilog-initial_display.log
|
|
|
|
diff yosys-initial_display.log iverilog-initial_display.log
|
2020-12-05 22:08:44 -06:00
|
|
|
|
|
|
|
test_always_display () {
|
|
|
|
local subtest=$1; shift
|
2023-06-27 20:51:11 -05:00
|
|
|
../../yosys -p "read_verilog $* always_display.v; proc; opt_expr -mux_bool; clean" -o yosys-always_display-${subtest}-1.v
|
|
|
|
../../yosys -p "read_verilog yosys-always_display-${subtest}-1.v; proc; opt_expr -mux_bool; clean" -o yosys-always_display-${subtest}-2.v
|
2020-12-05 22:08:44 -06:00
|
|
|
diff yosys-always_display-${subtest}-1.v yosys-always_display-${subtest}-2.v
|
|
|
|
}
|
|
|
|
|
|
|
|
test_always_display clk -DEVENT_CLK
|
|
|
|
test_always_display clk_rst -DEVENT_CLK_RST
|
|
|
|
test_always_display star -DEVENT_STAR
|
|
|
|
|
|
|
|
test_always_display clk_en -DEVENT_CLK -DCOND_EN
|
|
|
|
test_always_display clk_rst_en -DEVENT_CLK_RST -DCOND_EN
|
|
|
|
test_always_display star_en -DEVENT_STAR -DCOND_EN
|
|
|
|
|
|
|
|
test_roundtrip () {
|
|
|
|
local subtest=$1; shift
|
2023-06-27 20:51:11 -05:00
|
|
|
../../yosys -p "read_verilog $* roundtrip.v; proc; clean" -o yosys-roundtrip-${subtest}-1.v
|
|
|
|
../../yosys -p "read_verilog yosys-roundtrip-${subtest}-1.v; proc; clean" -o yosys-roundtrip-${subtest}-2.v
|
2020-12-05 22:08:44 -06:00
|
|
|
diff yosys-roundtrip-${subtest}-1.v yosys-roundtrip-${subtest}-2.v
|
|
|
|
|
|
|
|
iverilog $* -o iverilog-roundtrip-${subtest} roundtrip.v roundtrip_tb.v
|
|
|
|
./iverilog-roundtrip-${subtest} >iverilog-roundtrip-${subtest}.log
|
|
|
|
iverilog $* -o iverilog-roundtrip-${subtest}-1 yosys-roundtrip-${subtest}-1.v roundtrip_tb.v
|
|
|
|
./iverilog-roundtrip-${subtest}-1 >iverilog-roundtrip-${subtest}-1.log
|
|
|
|
iverilog $* -o iverilog-roundtrip-${subtest}-2 yosys-roundtrip-${subtest}-2.v roundtrip_tb.v
|
|
|
|
./iverilog-roundtrip-${subtest}-1 >iverilog-roundtrip-${subtest}-2.log
|
|
|
|
diff iverilog-roundtrip-${subtest}.log iverilog-roundtrip-${subtest}-1.log
|
|
|
|
diff iverilog-roundtrip-${subtest}-1.log iverilog-roundtrip-${subtest}-2.log
|
|
|
|
}
|
|
|
|
|
|
|
|
test_roundtrip dec_unsigned -DBASE_DEC -DSIGN=""
|
|
|
|
test_roundtrip dec_signed -DBASE_DEC -DSIGN="signed"
|
|
|
|
test_roundtrip hex_unsigned -DBASE_HEX -DSIGN=""
|
|
|
|
test_roundtrip hex_signed -DBASE_HEX -DSIGN="signed"
|
|
|
|
test_roundtrip oct_unsigned -DBASE_HEX -DSIGN=""
|
|
|
|
test_roundtrip oct_signed -DBASE_HEX -DSIGN="signed"
|
|
|
|
test_roundtrip bin_unsigned -DBASE_HEX -DSIGN=""
|
|
|
|
test_roundtrip bin_signed -DBASE_HEX -DSIGN="signed"
|
2023-06-27 20:51:18 -05:00
|
|
|
|
2023-06-27 20:51:30 -05:00
|
|
|
test_cxxrtl () {
|
|
|
|
local subtest=$1; shift
|
|
|
|
|
|
|
|
../../yosys -p "read_verilog ${subtest}.v; write_cxxrtl -print-output std::cerr yosys-${subtest}.cc"
|
|
|
|
${CC:-gcc} -std=c++11 -o yosys-${subtest} -I../.. ${subtest}_tb.cc -lstdc++
|
|
|
|
./yosys-${subtest} 2>yosys-${subtest}.log
|
|
|
|
iverilog -o iverilog-${subtest} ${subtest}.v ${subtest}_tb.v
|
|
|
|
./iverilog-${subtest} |grep -v '\$finish called' >iverilog-${subtest}.log
|
|
|
|
diff iverilog-${subtest}.log yosys-${subtest}.log
|
|
|
|
}
|
|
|
|
|
|
|
|
test_cxxrtl always_full
|
|
|
|
test_cxxrtl always_comb
|
2023-06-27 20:51:21 -05:00
|
|
|
|
|
|
|
../../yosys -p "read_verilog display_lm.v" >yosys-display_lm.log
|
|
|
|
../../yosys -p "read_verilog display_lm.v; write_cxxrtl yosys-display_lm.cc"
|
2023-06-27 20:51:29 -05:00
|
|
|
${CC:-gcc} -std=c++11 -o yosys-display_lm_cc -I../.. display_lm_tb.cc -lstdc++
|
2023-06-27 20:51:21 -05:00
|
|
|
./yosys-display_lm_cc >yosys-display_lm_cc.log
|
|
|
|
for log in yosys-display_lm.log yosys-display_lm_cc.log; do
|
|
|
|
grep "^%l: \\\\bot\$" "$log"
|
|
|
|
grep "^%m: \\\\bot\$" "$log"
|
|
|
|
done
|