使用OSERDESE2原语实现7bit并行数据转为1bit串行数据,根据手册配置之后,发现串行数据无输出,经过参考其他设计,发现RST需要置地,可以修改为~rst_n,或者!rst_n,即可以正常输出;尝试修改为1’b0,输出异常,因为该port默认为高复位;初次使用时,容易在这个地方卡壳;下边是仿真ok的代码
`timescale 1ns / 1ps
module generate_for(
input sys_clk_i,
input ext_rst_n, //复位信号,低电平有效
output tx_clk_out
);
wire clk70m;
wire clk10m;
wire rst_n;
wire [6:0] clk_pattern = 7’b1100001;
clk_wiz_0 instance_name
(
// Clock out ports
.clk_out1(clk70m), // output clk_out1
.clk_out2(clk10m), // output clk_out2
// Status and control signals
.resetn(ext_rst_n), // input resetn
.locked(rst_n), // output locked
// Clock in ports
.clk_in1(sys_clk_i)); // input clk_in1
OSERDESE2 #(
.DATA_RATE_OQ(“SDR”), // DDR, SDR
.DATA_RATE_TQ(“SDR”), // DDR, BUF, SDR
.DATA_WIDTH(7), // Parallel data width (2-8,10,14)
.INIT_OQ(1’b0), // Initial value of OQ output (1’b0,1’b1)
.INIT_TQ(1’b0), // Initial value of TQ output (1’b0,1’b1)
.SERDES_MODE(“MASTER”), // MASTER, SLAVE
.SRVAL_OQ(1’b0), // OQ output value when SR is used (1’b0,1’b1)
.SRVAL_TQ(1’b0), // TQ output value when SR is used (1’b0,1’b1)
.TBYTE_CTL(“FALSE”), // Enable tristate byte operation (FALSE, TRUE)
.TBYTE_SRC(“FALSE”), // Tristate byte source (FALSE, TRUE)
.TRISTATE_WIDTH(1) // 3-state converter width (1,4)
)
OSERDESE2_inst (
.OFB(), // 1-bit output: Feedback path for data
.OQ(tx_clk_out), // 1-bit output: Data path output
// SHIFTOUT1 / SHIFTOUT2: 1-bit (each) output: Data output expansion (1-bit each)
.SHIFTOUT1(),
.SHIFTOUT2(),
.TBYTEOUT(), // 1-bit output: Byte group tristate
.TFB(), // 1-bit output: 3-state control
.TQ(), // 1-bit output: 3-state control
.CLK(clk70m), // 1-bit input: High speed clock
.CLKDIV(clk10m), // 1-bit input: Divided clock
// D1 - D8: 1-bit (each) input: Parallel data inputs (1-bit each)
. D8 (),
. D7 (clk_pattern[6]),
. D6 (clk_pattern[5]),
. D5 (clk_pattern[4]),
. D4 (clk_pattern[3]),
. D3 (clk_pattern[2]),
. D2 (clk_pattern[1]),
. D1 (clk_pattern[0]),
.OCE(1’b1), // 1-bit input: Output data clock enable
.RST(~rst_n), // 1-bit input: Reset 这个rst不能直接写1’b0,否则OQ将无输出
// SHIFTIN1 / SHIFTIN2: 1-bit (each) input: Data input expansion (1-bit each)
.SHIFTIN1(1’b0),
.SHIFTIN2(1’b0),
// T1 - T4: 1-bit (each) input: Parallel 3-state inputs
.T1(1’b1),
.T2(1’b0),
.T3(1’b0),
.T4(1’b0),
.TBYTEIN(1’b0), // 1-bit input: Byte group tristate
.TCE(1’b0) // 1-bit input: 3-state clock enable
);
// End of OSERDESE2_inst instantiation
endmodule
module testbench(
);
reg sys_clk_i ;
reg ext_rst_n ;
wire tx_clk_out ;
generate_for my_test(
. sys_clk_i (sys_clk_i ),
. ext_rst_n ( ext_rst_n ),
. tx_clk_out ( tx_clk_out )
);
always #10 sys_clk_i = ~sys_clk_i;
initial
begin
sys_clk_i=1;
ext_rst_n=1;
#200 ext_rst_n = 0;
#200 ext_rst_n = 1;
#1000 $stop;
end