chipsalliance / firrtl

Flexible Intermediate Representation for RTL
https://www.chisel-lang.org/firrtl/
Apache License 2.0
719 stars 176 forks source link

Puzzling FIRRTL error #105

Closed zhemao closed 8 years ago

zhemao commented 8 years ago

Got this FIRRTL error in Travis.

https://travis-ci.org/ucb-bar/rocket-chip/jobs/120801507#L1274

What does this mean, exactly. Is it an internal FIRRTL issue?

jackkoenig commented 8 years ago

Yeah match errors should never happen, it's definitely an internal error. The good news is I'm in the process of revamping that pass, I'll make sure I fix whatever this is in the process. On Apr 4, 2016 10:16 PM, "Howard Mao" notifications@github.com wrote:

Got this FIRRTL error in Travis.

https://travis-ci.org/ucb-bar/rocket-chip/jobs/120801507#L1274

What does this mean, exactly. Is it an internal FIRRTL issue?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/ucb-bar/firrtl/issues/105

azidar commented 8 years ago

Yes, it is definitely a FIRRTL bug - can I see the FIRRTL source?

jackkoenig commented 8 years ago

@azidar I'm about to PR some major changes to LowerTypes which is where the match error is, so I wouldn't look at this until then.

azidar commented 8 years ago

The problem is a WSubAccess has leaked out of the "RemoveAccesses" passes - there shouldn't be anything wrong with the LowerTypes pass (with respect to this error), so it is probably independent of your PR. However, if you'd rather wait, that's fine with me.

jackkoenig commented 8 years ago

Oh yeah, you're right. Nevermind, no reason to wait.

zhemao commented 8 years ago

If you want to reproduce, checkout the axi-fix branch of RocketChip and try to build with NastiConverterTestConfig.

jackkoenig commented 8 years ago

Here's a small example that causes the error:

This FIRRTL file can be compiled and executed as a test

circuit NestedSubAccessTester :                                                                                                        
  module NestedSubAccess :                                                                                                             
    input foo : UInt<1>[4]                                                                                                             
    input index : UInt<2>                                                                                                              
    output out : UInt<4>                                                                                                               

    wire vec : UInt<4>[2]                                                                                                              
    vec[0] <= UInt(3)                                                                                                                  
    vec[1] <= UInt(4)                                                                                                                  

    out <= vec[foo[index]]                                                                                                             

  module NestedSubAccessTester :                                                                                                       
    input clk : Clock                                                                                                                  
    input reset : UInt<1>                                                                                                              

    inst dut of NestedSubAccess                                                                                                                                                                                                                                               

    dut.foo is invalid                                                                                                                 
    dut.index <= UInt(2)                                                                                                               
    dut.foo[2] <= UInt(1)                                                                                                              

    when neq(dut.out, UInt(4)) :                                                                                                       
      printf(clk, not(reset), "Assertion failed\nTest Failed!\n")                                                                      
      stop(clk, not(reset), 1)                                                                                                         
    else :                                                                                                                             
      stop(clk, not(reset), 0)                          
jackkoenig commented 8 years ago

I've created a branch that has a test that will fail until this is fixed

https://github.com/ucb-bar/firrtl/tree/fix-remove-subaccess