From f44778fa56f957b559664c0255441a11ed619073 Mon Sep 17 00:00:00 2001 From: Howard Mao Date: Mon, 6 Jun 2016 17:45:04 -0700 Subject: [PATCH] make sure Cached generator comparison truncates to correct size --- groundtest/src/main/scala/generator.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/groundtest/src/main/scala/generator.scala b/groundtest/src/main/scala/generator.scala index b62c1eb6..51b12126 100644 --- a/groundtest/src/main/scala/generator.scala +++ b/groundtest/src/main/scala/generator.scala @@ -176,8 +176,17 @@ class HellaCacheGenerator(id: Int) io.finished := (state === s_finished) + def data_match(recv: Bits, expected: Bits): Bool = { + val recv_resized = Wire(Bits(width = genWordBits)) + val exp_resized = Wire(Bits(width = genWordBits)) + + recv_resized := recv + exp_resized := expected + recv_resized === exp_resized + } + assert(!io.mem.resp.valid || !io.mem.resp.bits.has_data || - io.mem.resp.bits.data(genWordBits - 1, 0) === req_data, + data_match(io.mem.resp.bits.data, req_data), s"Received incorrect data in cached generator ${id}") }