chipyard icon indicating copy to clipboard operation
chipyard copied to clipboard

Error during Verilog generation (firtool pass) for a simple SInt-based Queue peripheral

Open milovanovic opened this issue 3 years ago • 2 comments

Background Work

Chipyard Version and Hash

Release: 1.9.0 and subsequent ones (1.9.1 and 1.10.0). Hash: 7475bfb

Works fine on 1.8.1 and before.

OS Setup

Any Linux

Other Setup

N/A

Current Behavior

When using the Chipyard's makefile flow to generate Verilog for Queue peripheral with SInt (or FixedPoint) data type, the following problem occurs during the execution of firtool command inside common.mk:

Decoupled.scala:273:95: error: memories should be flattened before running LowerMemory
Decoupled.scala:273:95: note: see current operation: %4:2 = "firrtl.mem"() {annotations = [], depth = 2 : i64, name = "ram", nameKind = #firrtl<name_kind droppable_name>, portAnnotations = [[], []], portNames = ["MPORT", "io_deq_bits_MPORT"], readLatency = 0 : i32, ruw = 0 : i32, writeLatency = 1 : i32} : () -> (!firrtl.bundle<addr: uint<1>, en: uint<1>, clk: clock, data: sint<16>, mask: uint<1>>, !firrtl.bundle<addr: uint<1>, en: uint<1>, clk: clock, data flip: sint<16>>)

The Queue code example is just a simple Queue "connected" to the bus, the code can be found here.

This problem occurred somewhere between tags 1.8.1 and 1.9.0 because the same makefile flow works fine on Chipyard version 1.8.1 but fails on version 1.9.0 and above. It should be noted that no problem is observed when UInt data type is supplied to Queue. The main issue is that the flow for SInt-based Queue is broken.

Please see this for more details on how to reproduce the error.

Expected Behavior

Generates Verilog for Queue peripheral with SInt (or FixedPoint) input data type, just as it does for UInt.

On Chipyard version 1.8.1 everything worked as expected.

Other Information

See Chipyard v1.9.0 to reproduce the SInt Queue error.

See Chipyard v1.8.1 to observe the expected behavior.

milovanovic avatar Jul 21 '23 08:07 milovanovic

I was able to reproduce this pretty easily, any Queue[SInt] seems to break for me. Can you work around this for now by creating a SIntQueue wrapper that converts type to UInt before instantiating the queue?

jerryz123 avatar Jul 25 '23 16:07 jerryz123

Actually, besides Queue the very same problem occurs also for memories, i.e. SInt-based Mem and SyncReadMem. Please see this for more details on how to reproduce the error.

milovanovic avatar Jan 02 '24 19:01 milovanovic