combine logical expression for StaticMemeoryTranslatorPlugin used in VexRiscv

70 Views Asked by At

I want to use 2 static memory regions for a vexriscv soc using SpinalHdl.

Having very little experience with SpinalHdl and Scala, so maybe I miss a small detail.

  • I tried this to instantiate 2 StaticMemoryTranslatorPlugins :

          plugins ++= List(
          new StaticMemoryTranslatorPlugin(
            ioRange      = _.msb 
          ),
          new StaticMemoryTranslatorPlugin(
            ioRange      = _(31 downto 16) === 0x0001
          ))
    

This gives an exception during cpu-generation.

[error] Exception in thread "main" java.lang.AssertionError: assertion failed: ??? vexriscv.MemoryTranslator
[error]     at scala.Predef$.assert(Predef.scala:170)
[error]     at spinal.core.package$.assert(core.scala:467) .....
  • Another way I tried is to combine the logical expression, as this :

            new StaticMemoryTranslatorPlugin(
                ioRange      = ( _.msb )  || ( _(31 downto 16) === 0x0001 )
              )
    

This gives me a scale error about expanding the fuction :

[error] /home/svhb/dev/JifHybrid/cpu/VexRiscv/src/main/scala/vexriscv/demo/VexRiscv_vdw_1.scala:125:36: missing parameter type for expanded function ((x$1) => x$1.msb)
[error]                   ioRange      = ( _.msb )  || ( _(31 downto 16) === 0x0001 )
[error]                                    ^
[error] one error found

Can someone point me in the right direction?

1

There are 1 best solutions below

0
On BEST ANSWER

Just like I thought, it's my lack of knowledge on the scala syntax itself.

I must fully specify the function to do some extra logic expressions on the iorange function!

new StaticMemoryTranslatorPlugin(
     ioRange      = a => (a.msb) || (a(31 downto 16) === 0x0001)
  )

instead of just using : ioRange = ( _.msb ) || ( _(31 downto 16) === 0x0001 )

Have a nice day;)