基于上一个问题,以下代码编译正常
trait Logger {
def log(msg: String): Unit
}
trait LoggerA extends Logger {
def log(msg: String) = ???
}
trait LoggerB extends Logger {
override def log(msg: String) = ???
}
class Logged1 extends LoggerA
class Logged2 extends LoggerB
class Logged3 extends LoggerA with LoggerB
Run Code Online (Sandbox Code Playgroud)
在override不要求LoggerA ,因为没有具体的实施log中Logger。
但是,如果我override从中删除LoggerB不再编译:
class Logged3 inherits conflicting members:
def log(msg: String): Nothing (defined in trait LoggerA) and
def log(msg: String): Nothing …Run Code Online (Sandbox Code Playgroud) Chisel 教程使用了似乎是<>操作符的东西,这对我来说是完全陌生的。它有什么作用?
还有,它从哪里来?这个运算符在其他 Scala 库甚至其他语言中是否有传统含义?
下面是一个使用示例,来自 Chisel Generator Bootcamp 练习,第 3.2 节:
class MyQueue extends Module {
// Example circuit using a Queue
val io = IO(new Bundle {
val in = Flipped(Decoupled(UInt(8.W)))
val out = Decoupled(UInt(8.W))
})
val queue = Queue(io.in, 2) // 2-element queue
io.out <> queue
}
Run Code Online (Sandbox Code Playgroud)