作者zxvc (众生都是未来佛)
看板Electronics
标题Re: [心得] SystemVerilog写pipeline registers
时间Fri Jun 25 13:41:35 2010
我发现一个更generic的写法,SystemVerilog居然支援像C++的template!!:
~~~~~~~~~~~~~~~~~~~~~~~~~~
typedef struct packed {
logic [5:0] a;
logic [1:0] [1:0] b;
} TestIn;
module Test(
output TestIn out,
output logic [5:0] out2,
input TestIn in,
input [5:0] in2,
input reset,
input clock
);
// Pipeline registers.
Dff #(TestIn) dffInst(out, in, reset, clock);
Dff #(logic [5:0]) dffInst2(out2, in2, reset, clock);
endmodule
module Dff #(parameter type T = logic) (q, d, reset, clock);
output T q;
input T d;
input reset;
input clock;
always_ff@(posedge clock or negedge reset) begin
if(!reset) begin
q <= 0;
end
else begin
q <= d;
end
end
endmodule
~~~~~~~~~~~~~~~~~~~~~~~~~~
以上code己用Design Compiler 2009.06合成过。
--
信佛的人要知道:佛绝不会说谎。但请把握时光。
法灭尽经:
http://www.cbeta.org/result/normal/T12/0396_001.htm
共勉之。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.71.32