-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to modify periphery to use other clock and cross clock #101
Comments
@borancar Would you have any idea? PS: I think github issues is much useful than sifive forums, because I can link the code and jump to source file easy. |
Depends what the relationship between the clocks will be. If the clocks have different frequencies and phases then you typically need AsynchronousCrossing. As for the mclock and mreset, you just need to pass it to the GPIOAttachParams and the magic will happen in attach: sifive-blocks/src/main/scala/devices/gpio/GPIO.scala Lines 239 to 240 in f79faa2
This is just what I think should be done, and Diplomacy will do its magic. Note that I haven't tried any of it yet. |
@borancar I notice
trait HasPeripheryGPIO { this: BaseSubsystem =>
val outside_mclock: Option[ModuleValue[Clock]]
val gpioXType = SynchronousCrossing // Here I use dafault options
val gpioNodes = p(PeripheryGPIOKey).map { ps => GPIO.attach(GPIOAttachParams(ps, pbus, ibus.fromAsync, controlXType=gpioXType)).ioNode.makeSink }
}
class E300ArtyDevKitSystem(mclock: Clock)(implicit p: Parameters) extends RocketSubsystem
with HasPeripheryMaskROMSlave
with HasPeripheryDebug
with HasPeripheryMockAON
with HasPeripheryUART
with HasPeripherySPIFlash
with HasPeripherySPI
with HasPeripheryGPIO
with HasPeripheryPWM
with HasPeripheryI2C {
override lazy val module = new E300ArtyDevKitSystemModule(this)
lazy val outside_mclock = Some(InModuleBody { clock })
}
class Platform(implicit val p: Parameters) extends RawModule {
val clock_25 = IO(Input(Clock()))
val clock_125 = IO(Input(Clock()))
val rstn = IO(Input(Bool()))
withClockAndReset(clock_125, ~rstn) {
val sys = Mdule(LazyModule(new E300ArtyDevKitSystem(clock_25)).module)
....
}
} But this failed: chisel3.internal.ChiselException: Connection between sink (chisel3.core.Clock@70cf8) and source (chisel3.core.Clock@3) failed @: Sink or source unavailable to current module. Shoule I write module maybe like |
I use different way to solve problem.
class GPIOPortIO(val c: GPIOParams) extends Bundle {
val new_clock = Input(Clock())
val new_reset = Input(Bool())
val pins = Vec(c.width, new EnhancedPin())
val iof_0 = if (c.includeIOF) Some(Vec(c.width, new IOFPin).flip) else None
val iof_1 = if (c.includeIOF) Some(Vec(c.width, new IOFPin).flip) else None
}
lazy val module = new LazyRawModuleImp(this) {
withClockAndReset(port.new_clock, port.new_reset) {
.....
}
} |
Take GPIO for example, there are
controlXType
andmclock
inGPIOAttachParams
.sifive-blocks/src/main/scala/devices/gpio/GPIO.scala
Lines 215 to 223 in f79faa2
The code below is to use it:
sifive-blocks/src/main/scala/devices/gpio/GPIOPeriphery.scala
Lines 10 to 12 in f79faa2
If I want to use other clock giving to GPIO, should I use
SynchronousCrossing
? So I would givecontrolXType
as below:But I don't know how to connect
mclock
from outside, such as GPIO's IO port.The text was updated successfully, but these errors were encountered: