Advertisement
Laserbeak43

Some Errors

May 25th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 4.85 KB | None | 0 0
  1. /*
  2.  * SpinalHDL
  3.  * Copyright (c) Dolu, All rights reserved.
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Lesser General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 3.0 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Lesser General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Lesser General Public
  16.  * License along with this library.
  17.  */
  18.  
  19. package MyCode
  20.  
  21. //import MyCode.VgaCtrl.{Rgb, VgaTimingsHV}
  22. import spinal.core._
  23. import spinal.lib._
  24. import spinal.lib.cpu.riscv.impl.UtilsTest.TopLevel
  25.  
  26.  
  27. class VgaCtrl(rgbConfig: RgbConfig, timingsWidth: Int = 12) extends Component {
  28.   val io = new Bundle {
  29.     val softReset = in Bool
  30.     val timings = in(VgaTimings(timingsWidth))
  31.     val colorStream = slave Stream (Rgb(rgbConfig))
  32.  
  33.     val error = out Bool
  34.     val frameStart = out Bool
  35.     val vga = master(Vga(rgbConfig))
  36.   }
  37.  
  38.   case class HVArea(timingsHV: VgaTimingsHV, enable: Bool) extends Area {
  39.     val counter = Reg(UInt(timingsWidth bit)) init(0)
  40.  
  41.     val syncStart  = counter === timingsHV.syncStart
  42.     val syncEnd    = counter === timingsHV.syncEnd
  43.     val colorStart = counter === timingsHV.colorStart
  44.     val colorEnd   = counter === timingsHV.colorEnd
  45.  
  46.     when(enable) {
  47.       counter := counter + 1
  48.       when(syncEnd) {
  49.         counter := 0
  50.       }
  51.  
  52.       val h = HVArea(io.timings.h, True)
  53.       val v = HVArea(io.timings.v, h.syncEnd)
  54.  
  55.       val colorEn = h.colorEn && v.colorEn
  56.       io.pixels.ready := colorEn
  57.       io.error := colorEn && ! io.pixels.valid
  58.  
  59.       io.frameStart := v.syncEnd
  60.  
  61.       io.vga.hSync := h.sync
  62.       io.vga.vSync := v.sync
  63.       io.vga.colorEn := colorEn
  64.       io.vga.color := io.pixels.payload
  65.  
  66.     }
  67.  
  68.     val sync    = RegInit(False) setWhen(syncStart) clearWhen(syncEnd)
  69.     val colorEn = RegInit(False) setWhen(colorStart) clearWhen(colorEnd)
  70.  
  71.     when(io.softReset) {
  72.       counter := 0
  73.       sync    := False
  74.       colorEn := False
  75.     }
  76.   }
  77.  
  78.   val h = HVArea(io.timings.h, True)
  79.   val v = HVArea(io.timings.v, h.syncEnd)
  80. }
  81.  
  82. case class RgbConfig(rWidth : Int,gWidth : Int,bWidth : Int){
  83.   def getWidth = rWidth + gWidth + bWidth
  84. }
  85.  
  86. case class Rgb(c: RgbConfig) extends Bundle{
  87.   val r = UInt(c.rWidth bit)
  88.   val g = UInt(c.gWidth bit)
  89.   val b = UInt(c.bWidth bit)
  90. }
  91.  
  92. case class Vga (rgbConfig: RgbConfig) extends Bundle with IMasterSlave{
  93.   val vSync = Bool
  94.   val hSync = Bool
  95.  
  96.   val colorEn = Bool
  97.   val color   = Rgb(rgbConfig)
  98.  
  99.   override def asMaster() = this.asOutput()
  100.   override def asSlave()  = this.asInput()
  101. }
  102.  
  103. case class VgaTimingsHV(timingsWidth: Int) extends Bundle {
  104.   val colorStart = UInt(timingsWidth bit)
  105.   val colorEnd   = UInt(timingsWidth bit)
  106.   val syncStart  = UInt(timingsWidth bit)
  107.   val syncEnd    = UInt(timingsWidth bit)
  108. }
  109.  
  110. case class VgaTimings(timingsWidth: Int) extends Bundle {
  111.   val h = VgaTimingsHV(timingsWidth)
  112.   val v = VgaTimingsHV(timingsWidth)
  113.  
  114.   def setAs_h640_v480_r60: Unit = {
  115.     h.syncStart := 96 - 1
  116.     h.syncEnd := 800 - 1
  117.     h.colorStart := 96 + 16 - 1
  118.     h.colorEnd := 800 - 48 - 1
  119.     v.syncStart := 2 - 1
  120.     v.syncEnd := 525 - 1
  121.     v.colorStart := 2 + 10 - 1
  122.     v.colorEnd := 525 - 33 - 1
  123.   }
  124.  
  125.   def setAs_h64_v64_r60: Unit = {
  126.     h.syncStart := 96 - 1
  127.     h.syncEnd := 800 - 1
  128.     h.colorStart := 96 + 16 - 1 + 288
  129.     h.colorEnd := 800 - 48 - 1 - 288
  130.     v.syncStart := 2 - 1
  131.     v.syncEnd := 525 - 1
  132.     v.colorStart := 2 + 10 - 1 + 208
  133.     v.colorEnd := 525 - 33 - 1 - 208
  134.   }
  135. }
  136.  
  137. object VgaCtrl {
  138.   def main(args: Array[String]) {
  139.     SpinalVhdl(new TopLevel)
  140.   }
  141. }
  142.  
  143. /*Error:(68, 34) value setWhen is not a member of spinal.core.Bool
  144.     val sync    = RegInit(False) setWhen(syncStart) clearWhen(syncEnd)
  145.                                  ^
  146. Error:(69, 34) value setWhen is not a member of spinal.core.Bool
  147.     val colorEn = RegInit(False) setWhen(colorStart) clearWhen(colorEnd)
  148.                                  ^
  149. Error:(56, 10) value pixels is not a member of spinal.core.Bundle{val softReset: spinal.core.Bool; val timings: MyCode.VgaTimings; val colorStream: spinal.lib.Stream[MyCode.Rgb]; val error: spinal.core.Bool; val frameStart: spinal.core.Bool; val vga: MyCode.Vga}
  150.       io.pixels.ready := colorEn
  151.          ^
  152. Error:(64, 26) value pixels is not a member of spinal.core.Bundle{val softReset: spinal.core.Bool; val timings: MyCode.VgaTimings; val colorStream: spinal.lib.Stream[MyCode.Rgb]; val error: spinal.core.Bool; val frameStart: spinal.core.Bool; val vga: MyCode.Vga}
  153.       io.vga.color := io.pixels.payload
  154.                          ^*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement