mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-21 21:26:42 +00:00
Change tests/memfile to a mktest, moving the prior run-test.sh contents into a new read_dir.sh. Add dump.ys (and friends) for testing dump_meminit.
62 lines
1.6 KiB
Text
62 lines
1.6 KiB
Text
# create sub dir
|
|
!mkdir -p temp
|
|
# remove output files
|
|
!rm -f gold.m.mem
|
|
!rm -f temp/gold.m.mem
|
|
|
|
# load test design
|
|
read_rtlil dump_gold.il
|
|
design -save gold
|
|
|
|
# dump_meminit sets INIT_FILE and unsets INIT
|
|
select -assert-any t:$__MEMORY r:INIT %i
|
|
select -assert-none t:$__MEMORY r:INIT_FILE %i
|
|
dump_meminit
|
|
select -assert-none t:$__MEMORY r:INIT %i
|
|
select -assert-any t:$__MEMORY r:INIT_FILE %i
|
|
# memory written to file
|
|
!test -f gold.m.mem
|
|
# file name in INIT_FILE
|
|
select -assert-any t:$__MEMORY r:INIT_FILE=gold.m.mem %i
|
|
|
|
design -load gold
|
|
dump_meminit -prefix temp/
|
|
# memory written to sub directory
|
|
!test -f temp/gold.m.mem
|
|
# sub directory in INIT_FILE
|
|
select -assert-any t:$__MEMORY r:INIT_FILE=temp/gold.m.mem %i
|
|
|
|
# dump_gate.v calls $readmemh with memory output from dump_gold.il
|
|
design -reset
|
|
read_verilog dump_gate.v
|
|
proc
|
|
design -save gate_proc
|
|
|
|
# infer memory for gate
|
|
memory -nomap
|
|
select -assert-any t:$mem_v2
|
|
design -save gate_memory
|
|
|
|
# memory read from output of dump_meminit has the same value as the RTLIL
|
|
select -assert-any t:$mem_v2 r:INIT=32'hdeadbeef %i
|
|
|
|
design -load gold
|
|
select -assert-any t:$__MEMORY r:INIT=32'hdeadbeef %i
|
|
|
|
# dump_meminit does nothing if there are no cells with INIT
|
|
design -load gate_proc
|
|
select -assert-none r:INIT
|
|
dump_meminit
|
|
select -assert-none r:INIT_FILE
|
|
|
|
# change cell type since INIT_FILE param is invalid on $mem_v2
|
|
design -load gate_memory
|
|
chtype -set $__MEMORY gate/m
|
|
|
|
# dump_meminit on parsed memory
|
|
select -assert-none r:INIT_FILE
|
|
dump_meminit
|
|
select -assert-any r:INIT_FILE=gate.m.mem
|
|
|
|
# gold and gate dumps are identical
|
|
!diff -s gate.m.mem gold.m.mem
|