Esempio n. 1
0
def dinvalidate_test(name):
	test_harness.assemble_test('dinvalidate.s')
	result = test_harness.run_verilator(dump_file='obj/vmem.bin', dump_base=0x100, dump_length=4, 
		extra_args=['+trace=1', '+autoflushl2=1'])

	# 1. Check that the proper value was read into s2
	if result.find('02 deadbeef') == -1:
		raise TestException('incorrect value was written back ' + result)

	# 2. Read the memory dump to ensure the proper value is flushed from the L2 cache
	with open('obj/vmem.bin', 'rb') as f:
		val = f.read(4)
		if ord(val[0]) != 0xef or ord(val[1]) != 0xbe or ord(val[2]) != 0xad or ord(val[3]) != 0xde:
			raise TestException('memory contents were incorrect')
Esempio n. 2
0
def dinvalidate_test(name):
	test_harness.assemble_test('dinvalidate.s')
	result = test_harness.run_verilator(dump_file='obj/vmem.bin', dump_base=0x100, dump_length=4, 
		extra_args=['+trace=1', '+autoflushl2=1'])

	# 1. Check that the proper value was read into s2
	if result.find('02 deadbeef') == -1:
		raise TestException('incorrect value was written back ' + result)

	# 2. Read the memory dump to ensure the proper value is flushed from the L2 cache
	with open('obj/vmem.bin', 'rb') as f:
		numVal = struct.unpack('<L', f.read(4))[0]
		if numVal != 0xdeadbeef:
			print(hex(numVal))
			raise test_harness.TestException('memory contents were incorrect')
Esempio n. 3
0
def run_cosimulation_test(source_file):
	global emulator_args
	global verilator_args

	hexfile = test_harness.assemble_test(source_file)
	p1 = subprocess.Popen(verilator_args + [ '+bin=' + hexfile ], stdout=subprocess.PIPE)
	p2 = subprocess.Popen(emulator_args + [ hexfile ], stdin=p1.stdout, stdout=subprocess.PIPE)
	output = ''
	while True:
		got = p2.stdout.read(0x1000)
		if not got:
			break

		if verbose:
			print(str(got))
		else:
			output += str(got)

	p2.wait()
	time.sleep(1)	# Give verilator a chance to clean up
	p1.kill() 	# Make sure verilator has exited
	if p2.returncode != 0:
		raise test_harness.TestException('FAIL: cosimulation mismatch\n' + output)

	test_harness.assert_files_equal(VERILATOR_MEM_DUMP, EMULATOR_MEM_DUMP,
		'final memory contents to not match')
Esempio n. 4
0
def dinvalidate_test(name):
    test_harness.assemble_test('dinvalidate.s')
    result = test_harness.run_verilator(
        dump_file='obj/vmem.bin',
        dump_base=0x100,
        dump_length=4,
        extra_args=['+trace=1', '+autoflushl2=1'])

    # 1. Check that the proper value was read into s2
    if result.find('02 deadbeef') == -1:
        raise TestException('incorrect value was written back ' + result)

    # 2. Read the memory dump to ensure the proper value is flushed from the L2 cache
    with open('obj/vmem.bin', 'rb') as f:
        numVal = struct.unpack('<L', f.read(4))[0]
        if numVal != 0xdeadbeef:
            print(hex(numVal))
            raise test_harness.TestException('memory contents were incorrect')
Esempio n. 5
0
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 

import sys

sys.path.insert(0, '../..')
import test_harness

test_harness.assemble_test('dinvalidate.s')
result = test_harness.run_verilator(dump_file='obj/vmem.bin', dump_base=0x100, dump_length=4, 
	extra_args=['+regtrace=1', '+autoflushl2=1'])

# 1. Check that the proper value was read into s2
if result.find('02 deadbeef') == -1:
	print 'incorrect value was written back'
	sys.exit(1)

# 2. Read the memory dump to ensure the proper value is flushed from the L2 cache
with open('obj/vmem.bin', 'rb') as f:
	val = f.read(4)
	if ord(val[0]) != 0xef or ord(val[1]) != 0xbe or ord(val[2]) != 0xad or ord(val[3]) != 0xde:
		print 'FAIL: memory contents were incorrect'
		sys.exit(1)
Esempio n. 6
0
	verilator_args += [ '+randseed=' + os.environ['RANDSEED'] ]

emulator_args = [
	'../../bin/emulator',
	'-m',
	'cosim',
	'-d',
	'obj/mmem.bin,0x800000,0x400000'
]

if 'EMULATOR_DEBUG_ARGS' in os.environ:
	emulator_args += [ os.environ['EMULATOR_DEBUG_ARGS'] ]

for source_file in files:
	print 'testing ' + source_file,
	hexfile = test_harness.assemble_test(source_file)
	p1 = subprocess.Popen(verilator_args + [ '+bin=' + hexfile ], stdout=subprocess.PIPE)
	p2 = subprocess.Popen(emulator_args + [ hexfile ], stdin=p1.stdout, stdout=subprocess.PIPE)
	p1.stdout.close() # Allow P1 to receive SIGPIPE if p2 exits
	while True:
		got = p2.stdout.read(0x1000)
		if not got:
			break
			
		print got

	if not test_harness.assert_files_equal(VERILATOR_MEM_DUMP, EMULATOR_MEM_DUMP):
		print "FAIL: simulator final memory contents do not match"
		sys.exit(1)
	else:
		print 'PASS'