| 1 |
`default_nettype none |
| 2 |
/* |
| 3 |
* This example allows you to generate OSER4 primitive and then check |
| 4 |
* iit with a logic analyzer. The PCLK, FCLK and Q outputs of the primitives |
| 5 |
* are connected to the board pins. |
| 6 |
*/ |
| 7 |
module top(input wire clk, |
| 8 |
input wire rst_i, |
| 9 |
output wire oser_out, |
| 10 |
output wire pclk_o, |
| 11 |
output wire fclk_o); |
| 12 |
|
| 13 |
wire aux_wire; |
| 14 |
IODELAY delay0( |
| 15 |
.DI(aux_wire), |
| 16 |
.DO(oser_out), |
| 17 |
.SDTAP(1'b0), |
| 18 |
.SETN(1'b1), |
| 19 |
.VALUE(1'b0), |
| 20 |
.DF() |
| 21 |
); |
| 22 |
|
| 23 |
defparam delay0.C_STATIC_DLY=100; |
| 24 |
|
| 25 |
wire rst = rst_i ^ `INV_BTN; |
| 26 |
OSER4 os( |
| 27 |
.D0(1'b0), |
| 28 |
.D1(1'b1), |
| 29 |
.D2(1'b0), |
| 30 |
.D3(1'b1), |
| 31 |
.TX0(1'b1), |
| 32 |
.TX1(1'b1), |
| 33 |
.FCLK(fclk_w), |
| 34 |
.PCLK(pclk_w), |
| 35 |
.RESET(1'b0), |
| 36 |
.Q0(aux_wire), |
| 37 |
.Q1() |
| 38 |
); |
| 39 |
defparam os.GSREN = "false"; |
| 40 |
defparam os.LSREN = "true"; |
| 41 |
|
| 42 |
wire clk_w; |
| 43 |
wire pclk_w; |
| 44 |
wire fclk_w; |
| 45 |
|
| 46 |
assign pclk_o = pclk_w; |
| 47 |
assign fclk_o = fclk_w; |
| 48 |
|
| 49 |
reg clkB; |
| 50 |
|
| 51 |
always@(negedge fclk_w) begin |
| 52 |
clkB <= ~clkB; |
| 53 |
end |
| 54 |
assign pclk_w = clkB; |
| 55 |
|
| 56 |
// slow |
| 57 |
reg [24:0] ctr_q; |
| 58 |
wire [24:0] ctr_d; |
| 59 |
wire tick_w; |
| 60 |
|
| 61 |
// Sequential code (flip-flop) |
| 62 |
always @(posedge clk) |
| 63 |
ctr_q <= ctr_d; |
| 64 |
|
| 65 |
// Combinational code (boolean logic) |
| 66 |
assign ctr_d = ctr_q + 1'b1; |
| 67 |
assign tick_w = ctr_q[24]; |
| 68 |
|
| 69 |
assign fclk_w = tick_w; |
| 70 |
endmodule |