GithubHelp home page GithubHelp logo

Comments (15)

Dolu1990 avatar Dolu1990 commented on July 21, 2024

Hi, what do you mean by 1T ?

Currently, thigly coupled ram is supported for i$. for the d$ the user can use a peripheral memory mapped in IO region, but at a performance cost

from vexriscv.

piondeno avatar piondeno commented on July 21, 2024

Hi, Dolu1990
Thanks for your reply.
The 1T what I mean is that can IBusCachedPlugin fetch instruction only 1 clock delay after sending vailde PC address in some memory region.

Tightly coupled ram is that I want and I will try to generate TCM for testing it.
Thanks a lot.

from vexriscv.

Dolu1990 avatar Dolu1990 commented on July 21, 2024

I just find remembered that scratchpad is also supported for dbus :

def newTightlyCoupledPort(mapping : UInt => Bool) = {

from vexriscv.

piondeno avatar piondeno commented on July 21, 2024

Hi, Dolu1990
Thanks for reply again.
I am trying to implement TCM.
But I am a new one in SpinalHdl, encounter errors continuously.
I try to find the reference code for TCM and seems like none in "demo" folder.

I write the following code to generate TCM, but not success.

  for(plugin <- config.plugins) plugin match{
    //case plugin : IBusSimplePlugin => iBus = plugin.iBus.toAxi4ReadOnly()
    case plugin : IBusCachedPlugin => {
      iBus = plugin.iBus.toAxi4ReadOnly()
      val iBusTc=plugin.newTightlyCoupledPortV2(TightlyCoupledPortParameter("iBusTc", a => a(31 downto 28) === 0x0 && a(10)))
      val tcmMemDataWidth = log2Up(1024)
      val tcmMem = new Mem(Bits(32 bits), wordCount = 1024)
      iBusTc.data := tcmMem.readSync(iBusTc.address((tcmMemDataWidth-1) downto 0),iBusTc.enable)
    }

Could you provide me a simple demo for TCM?
Thanks a lot.

from vexriscv.

Dolu1990 avatar Dolu1990 commented on July 21, 2024

Hi, I will add a demo

from vexriscv.

Dolu1990 avatar Dolu1990 commented on July 21, 2024

Done, see https://github.com/SpinalHDL/VexRiscv/blob/281818af9c04517baa7c6dffe62e229bfa7e036a/src/main/scala/vexriscv/demo/GenFullWithTcm.scala

from vexriscv.

piondeno avatar piondeno commented on July 21, 2024

Thanks for the demo.
After download the file and run this demo, it shows one error.

/home/datakey/tools/VexRiscV/VexRiscv-Idea/src/main/scala/vexriscv/demo/GenFullWithTcm.scala:55:40 type mismatch; found : vexriscv.plugin.TightlyCoupledDataPortParameter required: spinal.core.UInt => spinal.core.Bool TightlyCoupledDataPortParameter("dBusTc", a => a(31 downto 28) === 0x3)

Do you encounter same status?
If it only occurs on my project, I will re-clone whole project again.

I mark line 54 and 55 off and only generate TCM for IBusCachedPlugin.
It can generate verilog code successfully.

I plan to use a single-port ram to implement TCM and make sure debug-port also can assess this TCM.
Thanks a lot.

from vexriscv.

Dolu1990 avatar Dolu1990 commented on July 21, 2024

Hi,

After download the file and run this demo, it shows one error.

You may have a too hold vexriscv, need to update it i guess.

Also, note that i pushed another example which integrate the memory directly in VexRiscv, but as a dual ported blackbox :
beeec94#diff-c6e62ed4d29d36f377790574498f2dc058f029a2a88e0c5b45f22d502658aaca

from vexriscv.

piondeno avatar piondeno commented on July 21, 2024

Hi Dolu1990, thanks for your help.

After re-download the vexriscv, there is no error on previous demo file.
I will try the new demo file, thanks a lot.

from vexriscv.

piondeno avatar piondeno commented on July 21, 2024

Hi @Dolu1990,

May I ask for your help?

First, I want to single-port to implement TCM and rewrite the code for build.

  override def build(pipeline: VexRiscv) = {
    val logic = pipeline plug new Area {
      val ram = Mem(Bits(32 bits), mapping.size.toInt/4)
//      ram.generateAsBlackBox()
      val address = Mux(ibus.enable,(ibus.address >> 2),(dbus.address >> 2)).resized
      val tcmRam = new Area{
        val readData = ram.readWriteSync(
            address = address,
            data    = dbus.write_data,
            enable  = (dbus.enable | ibus.enable),
            write   = dbus.write_enable,
            mask    = dbus.write_mask
          )
        dbus.read_data := readData
        ibus.data := readData
      }

Second, I generate two TCM for ITCM and DTCM.

  val ITCM = new IBusDBusCachedTightlyCoupledRam(
    mapping = SizeMapping(0x20000000, 0x2000)
  )
  val DTCM = new IBusDBusCachedTightlyCoupledRam(
    mapping = SizeMapping(0x30000000, 0x1000)
  )

Third, modify the ld file to seperate code and data.
And seperate the hex file as two parts for simulation.
One is for ITCM and the other for DTCM.

MEMORY {
  iTcm (WX!R)/*(RX)*/ : ORIGIN = 0x20000000, LENGTH = 8K
  dTcm (W!RX) : ORIGIN = 0x30000000, LENGTH = 4K
}
_stack_size = 2k;
_heap_size = 0k;

SECTIONS /*TODO don't initialize useless things,  restore literal loading that use 2 instruction in place of onChipRam word */
{
  .vector : {
    *crt.o(.text);
  } > iTcm

  .memory : {
    *(.text);
    end = .;
  } > iTcm

  .rodata         :
  {
    *(.rdata)
    *(.rodata .rodata.*)
    *(.gnu.linkonce.r.*)
  } > dTcm

Fourth, I try to use HexTools.initRam() to initial the content of TCM RAM for simulation.
But I can not find the hierarchy that can point to the RAM of TCM.
Could you give me some suggestion ?

HexTools.initRam(toplevel.axi.???, "/home/datakey/myProject/VexRiscvSocSoftware-master/projects/briey/timer/build/timerITCM.hex", 0x20000000l)
HexTools.initRam(toplevel.axi.???, "/home/datakey/myProject/VexRiscvSocSoftware-master/projects/briey/timer/build/timerDTCM.hex", 0x30000000l)

Ryan.zip

from vexriscv.

Dolu1990 avatar Dolu1990 commented on July 21, 2024

Hi,
I pushed more arguements to IBusDBusCachedTightlyCoupledRam
Currently, the idea of the IBusDBusCachedTightlyCoupledRam.
See 7c6c7a6#diff-106774d0f914a0abb624dcdc0ad496761640bbabb69f5d287f5639e38debdb9aR654

So, you need to set ramAsBlackbox=false hexInit=pathOfHexFile ramOffset=offsetAtWhichTheRamIsMapped

from vexriscv.

piondeno avatar piondeno commented on July 21, 2024

Thanks for @Dolu1990 once again.

I still make some modification for using single port sram like this

  override def build(pipeline: VexRiscv) = {
    val logic = pipeline plug new Area {
      val muxAddress = Mux(ibus.enable,(ibus.address >> 2),(dbus.address >> 2)).resized
      val muxEnable = (dbus.enable | ibus.enable)
      val ram = Mem(Bits(32 bits), mapping.size.toInt/4)
      if(ramAsBlackbox) ram.generateAsBlackBox()
      if (hexInit != null) {
        assert(ramOffset != -1)
        val temp = ramOffset.toBigInt
        initRam(ram, hexInit, temp, allowOverflow = true)
      }
      val tcmRam = new Area {
        val readData = ram.readWriteSync(
          address = muxAddress,
          data = dbus.write_data,
          enable = muxEnable,
          write = dbus.write_enable && dbus.enable,
          mask = dbus.write_mask
        )
        dbus.read_data := readData
        ibus.data := readData
      }
    }
  }

Now I can use load hex file to ITCM and DTCM directly and run the simulation successfully.
After programming the FPGA, I also can use debug port (JTAG) to download program into ITCM and DTCM.
Thanks

from vexriscv.

Dolu1990 avatar Dolu1990 commented on July 21, 2024

Hi,

I'm just a bit scared with that modification, because it seems that if the ibus and dbus acess at the same time, then dbus request will be ignored ?

from vexriscv.

piondeno avatar piondeno commented on July 21, 2024

Hi,
linkerTcm.zip

First, I use linkerTcm.ld to separate .text and .data
And generate ITCM for .text and DTCM for .data
In the simulation, I did not see any request from dbus.enable in ITCM bus.

Second, run the debug mode in eclipse IDE.
It is OK to download program.
I can set break point , run single step and not encounter any problem and crash right now.
It seems like no collision in debug mode.

If you need more testing, please let me know.
Thanks

from vexriscv.

Dolu1990 avatar Dolu1990 commented on July 21, 2024

Ahhh ok ^^
I understand now,
Thanks

from vexriscv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.