chipyard icon indicating copy to clipboard operation
chipyard copied to clipboard

How can I generate a reset_vector io at DigitalTop module?

Open csgxiong opened this issue 2 years ago • 22 comments

Background Work

Feature Description

How can I generate a reset_vector io at DigitalTop module? I want to use the custom reset_vector values to be the boot address. So What should I do?

Thank you!

Motivating Example

I want to use the custom reset_vector values to be the boot address. So What should I do?

Thank you!

csgxiong avatar Jan 31 '24 12:01 csgxiong

I had to create this snippet in chipyard.IOBinders and added it to AbstractConfig to be able to pull it out to the DigitalTop level. Hope this helps!

class WithExternalResetVectorPunchthrough extends OverrideIOBinder({
  (system: HasTilesModuleImp) => {
    val io_rst_vector_pins_temp = system.reset_vector.zipWithIndex.map { case (dio, i) => IO(dio.cloneType).suggestName(s"rv_$i") }
    (io_rst_vector_pins_temp zip system.reset_vector).map { case (io, sysio) =>
      sysio := io 
    }
    (io_rst_vector_pins_temp, Nil)
  }
})

Kevin99214 avatar Feb 02 '24 00:02 Kevin99214

@Kevin99214 Thank you for your reply. I really appreciate it. I had tried your ways, but it does not work. I am using chipyard V1.10 and the "make verilog CONFIG=RocketConfig" command to generate RTL . Are there other steps need to be done after adding WithExternalResetVectorPunchthrough Config to AbstractConfig?

csgxiong avatar Feb 02 '24 01:02 csgxiong

Just to make sure but did you set this to true? case SubsystemExternalResetVectorKey => true

Kevin99214 avatar Feb 02 '24 01:02 Kevin99214

It is My mistake. Now when I set SubsystemExternalResetVectorKey to be true, the generator shows an exception: Diplomacy has detected a problem with your graph: The following node node has 1 inward connections and no outward connections.At least one outward connection was required. 1 inward nodes bound:[once-system.bootROMResetVectorSourceNode] 0 outward nodes bound:[]

csgxiong avatar Feb 02 '24 01:02 csgxiong

When I deleted all the bootrom related configs (withbootrom/withbootaddrReg/withcustombootpin), and set SubsystemExternalResetVectorKey to be true, it finally worked.But it seems there are too mange changes. Any ideas about it? Thanks!

csgxiong avatar Feb 02 '24 08:02 csgxiong

As far as I know, the bootrom needs a reset vector register to program as part of its boot code. If you want an external reset vector, that removes the register the bootrom needs and caused the error. (anyone please correct me if I'm wrong)

For my use case, I rather boot from the address I set using the external reset vector over the bootrom so removing those bootrom configs make sense. But that'll may be different for you. It's up to you to decide if this is what you want.

Kevin99214 avatar Feb 02 '24 21:02 Kevin99214

Setting the defaultBootAddress of BootAddrRegParams will make the bootrom jump to a different start address.

https://github.com/ucb-bar/testchipip/blob/60a1c15f963222331b8e4127b0ece0ea210786aa/src/main/scala/boot/Configs.scala#L17-L20

jerryz123 avatar Feb 02 '24 21:02 jerryz123

@Kevin99214 Yes. What I want to do is exactly using the external reset vector to boot the cores. Thank you for your reply.

csgxiong avatar Feb 04 '24 01:02 csgxiong

@jerryz123 Thank you, Jerry. I will give it a try.

csgxiong avatar Feb 04 '24 01:02 csgxiong

@csgxiong I also wanted to take out the reset vector out of the chiptop file. I have made the case class in BaseConfig.scala file and they try to invoke it from BaseConfig via AbstractConfig class. like

case object WithExternalResetVectorPort extends Config(
  (site, here, up) => {
    case SubsystemExternalResetVectorKey => true
  }
)

I got the same error like

parents: broadcast/system/chiptop0
locator:  (BundleBridge.scala:197:31)

1 inward nodes bound: [once-system.bootROMResetVectorSourceNode]
0 outward nodes bound: []

number of known := bindings to inward nodes: 1
number of known := bindings to outward nodes: 0
number of binding queries from inward nodes: 0
number of binding queries from outward nodes: 0

How did you solve this error ? I saw in comment section you solved this error.

ashu-bitspilani avatar Mar 05 '24 09:03 ashu-bitspilani

@ashutgupta28 Just like what I had mented before.

When I deleted all the bootrom related configs (withbootrom/withbootaddrReg/withcustombootpin), and set SubsystemExternalResetVectorKey to be true, it finally worked.

csgxiong avatar Mar 05 '24 09:03 csgxiong

@ashutgupta28 Ok, it seems to be a good way. I will give it a try later.

csgxiong avatar Mar 05 '24 09:03 csgxiong

@csgxiong Ok. can you tell me the exact changes you have done it for taken the external reset vector out. So that I can give a try. :-)

ashu-bitspilani avatar Mar 05 '24 10:03 ashu-bitspilani

@ashutgupta28 My steps are: 1.Delete "case BootROMLocated ***" at BaseSubsytemConfig 2.Delete "WithBootROM" + "WithCustomBootPin " + "WithBootAddrReg"+ "WithCustomBootPinPlusArg" at AbstractConfig Then it will work!

csgxiong avatar Mar 05 '24 10:03 csgxiong

@csgxiong I did the same steps as you mentioned and the RTL is generating but I want to ask you did any top level reset vector port was generating in Digital Top file in your case?

ashu-bitspilani avatar Mar 06 '24 06:03 ashu-bitspilani

@ashutgupta28 Yes. After doing the steps, there was a reset_vector_0 port at my DigitalTop.

csgxiong avatar Mar 06 '24 06:03 csgxiong

@ashutgupta28 Nice!! Well, I find there is a little difference between our work. I was using the default RocketConfig. It maybe the reasion before.

csgxiong avatar Mar 11 '24 06:03 csgxiong

@csgxiong So what ever the RTL it is generating in Frontend.v file that worked in RocketConfig ? Right.. In your case If that worked there then I assumed that it will also worked here also ..

ashu-bitspilani avatar Mar 11 '24 07:03 ashu-bitspilani

@csgxiong I have successfully achieved the reset vector and HartID out of the digitalTop Module. And it is fine . image

But in Chiptop module it is generating as the output and internally driving as zero. Any idea how can I change the port as output to input in Chiptop. image

ashu-bitspilani avatar Mar 13 '24 08:03 ashu-bitspilani

@ashutgupta28

@csgxiong I have successfully achieved the reset vector and HartID out of the digitalTop Module. And it is fine . image

But in Chiptop module it is generating as the output and internally driving as zero. Any idea how can I change the port as output to input in Chiptop. image

Hi! When I try to pull hart_id out of the digitalTop Module, the reset vector will disapear. How did you achieve this?

csgxiong avatar May 14 '24 07:05 csgxiong