Skip to content

Commit

Permalink
Merge pull request #298 from yrabbit/ioregs-m
Browse files Browse the repository at this point in the history
Implement FF in IO blocks.
  • Loading branch information
yrabbit authored Jan 4, 2025
2 parents 3bcb12a + f968e85 commit 53d746d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/himbaechel/ioregs.v
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 53d746d

Please sign in to comment.