From f968e85531ec52255257b86d8a032ddf6e729028 Mon Sep 17 00:00:00 2001 From: YRabbit Date: Sat, 14 Dec 2024 11:53:49 +1000 Subject: [PATCH] Implement FF in IO blocks. There are three registers in IO blocks: IREG, OREG, and TREG. Not in all of them, but only where there is IOLOGIC because these registers are part of it. Hence the first limitation: if FF is placed in an IO block, the rest of the IOLOGIC cannot be used. The second limitation is related to the fact that all three registers have common wires CLK, ClockEnable and LocalSetReset and this dictates the types of flipflop's - let's say DFF (in Gowin's implementation) requires a constant connection CE to VCC, so you can not use in the same IO block DFFE, which CE is a signal. Signed-off-by: YRabbit --- examples/himbaechel/ioregs.v | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/himbaechel/ioregs.v diff --git a/examples/himbaechel/ioregs.v b/examples/himbaechel/ioregs.v new file mode 100644 index 0000000..9fced95 --- /dev/null +++ b/examples/himbaechel/ioregs.v @@ -0,0 +1,30 @@ +module top ( + input clk, + input key_i, + input rst_i, + output [`LEDS_NR-1:0] led +); + +wire key = key_i ^ `INV_BTN; +wire reset = rst_i ^ `INV_BTN; + +reg [25:0] ctr_q; +wire [25:0] ctr_d; + +always @(posedge clk) begin + if (reset) begin + ctr_q <= ctr_d; + end +end + +reg [`LEDS_NR - 2:0] led_r; +assign led = {ctr_q[25:25], led_r}; +assign ctr_d = ctr_q + 1'b1; + +always @(posedge clk) begin + if (!key) begin + led_r <= ctr_q[25:25-(`LEDS_NR - 2)]; + end +end + +endmodule