0

しばらく前に、 D タイプ フリップフロップを説明するvhdl コードを書きました。コードの一部は次のとおりです。

if (clk'event and clk='1') then
      q <= d;
end if;

次の条件を実装するにはどうすればよいですか

clk'event

スカラ/チゼル言語で?

4

4 に答える 4

2

私はあなたの質問に少し混乱しています。一般的に言えば、チゼルには明示的な時計はありません。また、Chisel が提供する Reg() コンストラクトを使用するだけなので、独自のフリップフロップを作成する必要はありません。

例外は、複数のクロックドメインを扱っている場合です。その場合(とにかくユーザーマニュアルによると)、

val q = Reg(init=UInt(0), clock=myClock)

しかし、複数のクロック ドメインのハードウェア デザインで何をしているのかを本当に理解していない限り、これはお勧めしません。

于 2014-06-12T22:57:29.410 に答える
1

エラーは、レジスタを初期化して x と y のデフォルト値を指定する必要があるためだと思います: val x = Reg(init = UInt(0)) val y = Reg(init = UInt(0))

ただし、これは実際に VHDL コードと同等にしたいものだと思います。

  class DFF extends Module {
    val io = new Bundle
    {
      val d  = UInt(INPUT,  1)
      val q = UInt(OUTPUT, 1)
    }
    val out = Reg(UInt(width=1))
    when(Bool(true)) {
      out := io.d
    }
    io.q := out
  }
于 2014-05-23T20:38:09.680 に答える
-1

私は次のようなことを考えました:

class DFF extends Module { 

  val io = new Bundle { 
  val d  = UInt(INPUT,  1) 
  val ck  = UInt(INPUT, 1) 
  val q  = UInt(OUTPUT, 1) 
  val notq  = UInt(OUTPUT, 1)  
  } 

  val x  = Reg(UInt()) 
  val y  = Reg(UInt()) 

  x := io.q
  y := io.d

  when   (ck) { x := io.q; y:= x } 

}

どう思いますか?

于 2014-05-21T12:15:44.277 に答える
-1

明らかにそれは機能しません。DFF.scalaのコードを変更しました:

import Chisel._  

class DFF extends Module 
{ 

val io = new Bundle 
{ 
  val d  = UInt(INPUT,  1)  
  val en = Bool(INPUT)
  val q  = UInt(OUTPUT, 1) 
  val notq  = UInt(OUTPUT, 1)  
} 

val x  = Reg(UInt()) 
val y  = Reg(UInt()) 

when (io.en) { x := io.d; io.q := y; y := x } 
io.notq := !(io.q)
}

しかし、このコマンドを実行すると:

sbt "run main --backend v"

次のエラーが表示されます。

[info] Set current project to dff-project (in build file:/home/francesco/Scrivania/Chisel-Project/CHILA/DFF-project/)
[info] Running TestMain main --backend v
backend elaborate
// COMPILING class DFF(0)
started inference
finished inference (2)
start width checking
finished width checking
started flattening
finished flattening (6)
[warn] NativeMethodAccessorImpl.java:-2: 'main' is an unknown argument. in class sun.reflect.NativeMethodAccessorImpl
[error]: NO DEFAULT SPECIFIED FOR WIRE: /*? in class DFF*/ Chisel.UInt(OUTPUT, width=1, connect to 0 inputs: ()) in component class DFF
Re-running Chisel in debug mode to obtain erroneous line numbers...
backend elaborate
// COMPILING class DFF(0)
started inference
finished inference (2)
start width checking
finished width checking
started flattening
finished flattening (6)
[warn] NativeMethodAccessorImpl.java:-2: 'main' is an unknown argument. in class     sun.reflect.NativeMethodAccessorImpl
[error] DFF.scala:6: NO DEFAULT SPECIFIED FOR WIRE: /*? in class DFF*/ Chisel.UInt(OUTPUT,    width=1, connect to 0 inputs: ()) in component class DFF in class DFF
[error] (run-main-0) java.lang.IllegalStateException: CODE HAS 1 ERRORS and 1 WARNINGS
java.lang.IllegalStateException: CODE HAS 1 ERRORS and 1 WARNINGS
at Chisel.ChiselError$.checkpoint(ChiselError.scala:119)
at Chisel.Backend.elaborate(Backend.scala:674)
at Chisel.VerilogBackend.elaborate(Verilog.scala:1128)
at Chisel.Driver$.execute(Driver.scala:67)
at Chisel.Driver$.apply(Driver.scala:39)
at Chisel.Driver$.apply(Driver.scala:44)
at Chisel.chiselMain$.apply(hcl.scala:113)
at TestMain$.main(main.scala:8)
at TestMain.main(main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at      sun.ref lect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
 [error] Total time: 1 s, completed 21-mag-2014 14.37.31

私のmain.scalaは次のとおりです。

import Chisel._
import scala.collection.mutable.ArrayBuffer

object TestMain 
{
def main(args: Array[String]): Unit = 
{
    chiselMain(args, () => Module(new DFF()))   
}
}
于 2014-05-21T12:43:41.933 に答える