Skip to content

Commit 2331c55

Browse files
committed
moving some signals into continuous assignment for clarity
1 parent 13a8565 commit 2331c55

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/minipit.v

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,26 @@ module minipit (
2525
reg [15:0] counter;
2626
reg [15:0] current_count;
2727

28+
wire counter_tripped;
29+
assign counter_tripped = enable && r_counter_set && (current_count == (counter - 16'h1));
30+
2831
always @(posedge clk) begin
2932
if (!rst_n) begin
3033
counter <= 16'd10; // TODO: don't auto-set a counter
3134
current_count <= 16'd0;
3235
r_counter_set <= 1; // TODO: don't auto-enable a default counter
3336
r_interrupting <= 0;
34-
end else if (enable) begin
35-
if (write_enable) begin
36-
counter <= {counter_high, counter_low};
37-
end else begin
38-
r_counter_set <= 1;
39-
end
37+
counter <= 16'hA;
38+
r_counter_set <= 1;
39+
end else begin
40+
current_count <= current_count + 1;
4041

41-
if (counter_set) begin
42-
current_count <= current_count + 1;
43-
end else begin
44-
current_count <= current_count;
45-
end
46-
47-
if (counter_set && (current_count == (counter - 1))) begin
42+
if (counter_tripped) begin
4843
// pull interrupt line high for one clock cycle
4944
r_interrupting <= 1;
5045
if (repeating) begin
5146
current_count <= 0;
5247
end
53-
5448
end else begin
5549
r_interrupting <= 0;
5650
end

test/test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,23 @@ async def test_minipit_fires_every_ten_cycles(dut):
2020

2121
await ClockCycles(dut.clk, 1)
2222
dut.rst_n.value = 0
23+
# Pulling TRST low
24+
dut.ui_in.value = 0b0000_0000
25+
2326
await ClockCycles(dut.clk, 1)
2427
dut.rst_n.value = 1
28+
# Pulling TRST high again
29+
dut.ui_in.value = 0b0000_1000
30+
2531
# We need one cycle for interrupt setup
2632
await ClockCycles(dut.clk, 1)
2733
# TODO: fix uo_out[7] being X
2834
#assert dut.uo_out.value == 0x0
2935
assert dut.uo_out.value[0] == 0x0
3036
# After 10 clock cycles, minipit fires
3137
for i in range(5):
38+
# GATES=yes needs 11 due to what looks like latching in comparison
39+
# GATES=no needs 10
3240
await ClockCycles(dut.clk, 10)
3341
assert dut.uo_out.value[0] == 0x1
3442

0 commit comments

Comments
 (0)