Decoupled用法

Chisel Decoupled

Decoupled 即为接口包装一层valid 和 ready ,decoupled 默认方向为输出,如果需要输入,可以加.flip, Decoupled 可以直接调用Bundle或者Bits,Bundle 内的端口也应该用bits定义
example1 :

class testIO extends Bundle {
val a = Bits(3.W)
val b = Bits(2.W)
}
class testmodule extends Module{
val io = IO( new Bundle{
   val test = Decoupled(new testIO)

})
io.test.valid := io.test.ready
io.test.bits.a := 1.U
io.test.bits.b := 1.U

}
println(getVerilog(new testmodule))

生成的verilog为:

module cmd5Helpertestmodule(
  input        clock,
  input        reset,
  input        io_test_ready,
  output       io_test_valid,
  output [2:0] io_test_bits_a,
  output [1:0] io_test_bits_b
);
  assign io_test_valid = io_test_ready; // @[cmd5.sc 10:15]
  assign io_test_bits_a = 3'h1; // @[cmd5.sc 11:16]
  assign io_test_bits_b = 2'h1; // @[cmd5.sc 12:16]
endmodule

example2 :


class testmodule extends Module{
val io = IO( new Bundle{
   val test = Decoupled(Bits(3.W))
   val a = Input(UInt(2.W))
})
io.test.valid := io.test.ready
io.test.bits := 1.U


}
println(getVerilog(new testmodule))

生成的verilog:

module cmd7Helpertestmodule(
  input        clock,
  input        reset,
  input        io_test_ready,
  output       io_test_valid,
  output [2:0] io_test_bits,
  input  [1:0] io_a
);
  assign io_test_valid = io_test_ready; // @[cmd7.sc 6:15]
  assign io_test_bits = 3'h1; // @[cmd7.sc 7:14]
endmodule
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值