| 1 |
`default_nettype none |
| 2 |
/* |
| 3 |
* This example allows you to generate OSER4 primitive and then check |
| 4 |
* it 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 rst = rst_i ^ `INV_BTN; |
| 14 |
OSER4 os( |
| 15 |
.D0(1'b0), |
| 16 |
.D1(1'b1), |
| 17 |
.D2(1'b0), |
| 18 |
.D3(1'b1), |
| 19 |
.TX0(1'b1), |
| 20 |
.TX1(1'b1), |
| 21 |
.FCLK(fclk_w), |
| 22 |
.PCLK(pclk_w), |
| 23 |
.RESET(1'b0), |
| 24 |
.Q0(oser_out), |
| 25 |
.Q1() |
| 26 |
); |
| 27 |
defparam os.GSREN = "false"; |
| 28 |
defparam os.LSREN = "true"; |
| 29 |
|
| 30 |
wire clk_w; |
| 31 |
wire pclk_w; |
| 32 |
wire fclk_w; |
| 33 |
|
| 34 |
assign pclk_o = pclk_w; |
| 35 |
assign fclk_o = fclk_w; |
| 36 |
|
| 37 |
reg clkB; |
| 38 |
|
| 39 |
always@(negedge fclk_w) begin |
| 40 |
clkB <= ~clkB; |
| 41 |
end |
| 42 |
assign pclk_w = clkB; |
| 43 |
|
| 44 |
// slow |
| 45 |
reg [24:0] ctr_q; |
| 46 |
wire [24:0] ctr_d; |
| 47 |
wire tick_w; |
| 48 |
|
| 49 |
// Sequential code (flip-flop) |
| 50 |
always @(posedge clk) |
| 51 |
ctr_q <= ctr_d; |
| 52 |
|
| 53 |
// Combinational code (boolean logic) |
| 54 |
assign ctr_d = ctr_q + 1'b1; |
| 55 |
assign tick_w = ctr_q[24]; |
| 56 |
|
| 57 |
assign fclk_w = tick_w; |
| 58 |
endmodule |