Skip to content

Commit 53d746d

Browse files
authored
Merge pull request #298 from yrabbit/ioregs-m
Implement FF in IO blocks.
2 parents 3bcb12a + f968e85 commit 53d746d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

examples/himbaechel/ioregs.v

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module top (
2+
input clk,
3+
input key_i,
4+
input rst_i,
5+
output [`LEDS_NR-1:0] led
6+
);
7+
8+
wire key = key_i ^ `INV_BTN;
9+
wire reset = rst_i ^ `INV_BTN;
10+
11+
reg [25:0] ctr_q;
12+
wire [25:0] ctr_d;
13+
14+
always @(posedge clk) begin
15+
if (reset) begin
16+
ctr_q <= ctr_d;
17+
end
18+
end
19+
20+
reg [`LEDS_NR - 2:0] led_r;
21+
assign led = {ctr_q[25:25], led_r};
22+
assign ctr_d = ctr_q + 1'b1;
23+
24+
always @(posedge clk) begin
25+
if (!key) begin
26+
led_r <= ctr_q[25:25-(`LEDS_NR - 2)];
27+
end
28+
end
29+
30+
endmodule

0 commit comments

Comments
 (0)