| 1 |
`default_nettype none |
| 2 |
/* |
| 3 |
* This example allows you to generate OSER8 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 |
OSER8 os( |
| 15 |
.D0(1'b0), |
| 16 |
.D1(1'b1), |
| 17 |
.D2(1'b0), |
| 18 |
.D3(1'b1), |
| 19 |
.D4(1'b0), |
| 20 |
.D5(1'b1), |
| 21 |
.D6(1'b0), |
| 22 |
.D7(1'b1), |
| 23 |
.TX0(1'b1), |
| 24 |
.TX1(1'b1), |
| 25 |
.TX2(1'b1), |
| 26 |
.TX3(1'b1), |
| 27 |
.FCLK(fclk_w), |
| 28 |
.PCLK(pclk_r[1]), |
| 29 |
.RESET(1'b0), |
| 30 |
.Q0(oser_out) |
| 31 |
); |
| 32 |
defparam os.GSREN = "false"; |
| 33 |
defparam os.LSREN = "true"; |
| 34 |
defparam os.TXCLK_POL = 0; |
| 35 |
defparam os.HWL = "false"; |
| 36 |
|
| 37 |
reg [1:0]pclk_r; |
| 38 |
wire fclk_w; |
| 39 |
|
| 40 |
always @(posedge fclk_w) begin |
| 41 |
if (!rst) begin |
| 42 |
pclk_r <= 2'b00; |
| 43 |
end else begin |
| 44 |
pclk_r <= pclk_r + 2'b01; |
| 45 |
end |
| 46 |
end |
| 47 |
assign pclk_o = pclk_r[1]; |
| 48 |
assign fclk_o = fclk_w; |
| 49 |
|
| 50 |
// slow |
| 51 |
reg [24:0] ctr_q; |
| 52 |
wire [24:0] ctr_d; |
| 53 |
wire tick_w; |
| 54 |
|
| 55 |
// Sequential code (flip-flop) |
| 56 |
always @(posedge clk) |
| 57 |
ctr_q <= ctr_d; |
| 58 |
|
| 59 |
// Combinational code (boolean logic) |
| 60 |
assign ctr_d = ctr_q + 1'b1; |
| 61 |
assign tick_w = ctr_q[24]; |
| 62 |
|
| 63 |
assign fclk_w = tick_w; |
| 64 |
endmodule |