VGA
VGA总线
VGA总线通过Vga线束定义。
case class Vga (rgbConfig: RgbConfig) extends Bundle with IMasterSlave {
val vSync = Bool()
val hSync = Bool()
val colorEn = Bool() // High when the frame is inside the color area
val color = Rgb(rgbConfig)
override def asMaster() = this.asOutput()
}
VGA时序
VGA时序可以使用VgaTimings线束在硬件中建模:
case class VgaTimingsHV(timingsWidth: Int) extends Bundle {
val colorStart = UInt(timingsWidth bits)
val colorEnd = UInt(timingsWidth bits)
val syncStart = UInt(timingsWidth bits)
val syncEnd = UInt(timingsWidth bits)
}
case class VgaTimings(timingsWidth: Int) extends Bundle {
val h = VgaTimingsHV(timingsWidth)
val v = VgaTimingsHV(timingsWidth)
def setAs_h640_v480_r60 = ...
def driveFrom(busCtrl : BusSlaveFactory,baseAddress : Int) = ...
}
VGA控制器
现有VGA控制器,其定义如下:
case class VgaCtrl(rgbConfig: RgbConfig, timingsWidth: Int = 12) extends Component {
val io = new Bundle {
val softReset = in Bool()
val timings = in(VgaTimings(timingsWidth))
val frameStart = out Bool()
val pixels = slave Stream (Rgb(rgbConfig))
val vga = master(Vga(rgbConfig))
val error = out Bool()
}
// ...
}
frameStart
是一个在每个新帧开始时脉冲一个周期的信号。pixels
是一种颜色反压流,用于在需要时为VGA接口提供数据。当需要传输像素但没有对象时,
error
为高。