File tree Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Expand file tree Collapse file tree 2 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -25,32 +25,26 @@ module minipit (
25
25
reg [15 :0 ] counter;
26
26
reg [15 :0 ] current_count;
27
27
28
+ wire counter_tripped;
29
+ assign counter_tripped = enable && r_counter_set && (current_count == (counter - 16'h1 ));
30
+
28
31
always @(posedge clk) begin
29
32
if (! rst_n) begin
30
33
counter <= 16'd10 ; // TODO: don't auto-set a counter
31
34
current_count <= 16'd0 ;
32
35
r_counter_set <= 1 ; // TODO: don't auto-enable a default counter
33
36
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 ;
40
41
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
48
43
// pull interrupt line high for one clock cycle
49
44
r_interrupting <= 1 ;
50
45
if (repeating) begin
51
46
current_count <= 0 ;
52
47
end
53
-
54
48
end else begin
55
49
r_interrupting <= 0 ;
56
50
end
Original file line number Diff line number Diff line change @@ -20,15 +20,23 @@ async def test_minipit_fires_every_ten_cycles(dut):
20
20
21
21
await ClockCycles (dut .clk , 1 )
22
22
dut .rst_n .value = 0
23
+ # Pulling TRST low
24
+ dut .ui_in .value = 0b0000_0000
25
+
23
26
await ClockCycles (dut .clk , 1 )
24
27
dut .rst_n .value = 1
28
+ # Pulling TRST high again
29
+ dut .ui_in .value = 0b0000_1000
30
+
25
31
# We need one cycle for interrupt setup
26
32
await ClockCycles (dut .clk , 1 )
27
33
# TODO: fix uo_out[7] being X
28
34
#assert dut.uo_out.value == 0x0
29
35
assert dut .uo_out .value [0 ] == 0x0
30
36
# After 10 clock cycles, minipit fires
31
37
for i in range (5 ):
38
+ # GATES=yes needs 11 due to what looks like latching in comparison
39
+ # GATES=no needs 10
32
40
await ClockCycles (dut .clk , 10 )
33
41
assert dut .uo_out .value [0 ] == 0x1
34
42
You can’t perform that action at this time.
0 commit comments