Skip to content

Commit

Permalink
make interrupt fire on 10 rather than 11, other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stevej committed Oct 31, 2024
1 parent bbe0e3d commit ddf1203
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
a.out
.idea
*.vcd
runs
Expand Down
4 changes: 2 additions & 2 deletions src/byte_transmitter.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module byte_transmitter (
input clk,
input reset,
input enable,
// TODO: make [31:0] configurable
// TODO: make size configurable
input wire [31:0] in, // byte_buffer
output wire out,
output wire done
Expand Down Expand Up @@ -38,7 +38,7 @@ module byte_transmitter (
`ifdef FORMAL
f_total_written <= f_total_written + 1;
assert (r_out != 1'bX);
assert (byte_count != 1'bX);
assert (byte_count != 5'bX_XXXX);
assert (in[byte_count-1] != 1'bX);
`endif
r_out <= in[byte_count-1];
Expand Down
6 changes: 3 additions & 3 deletions src/minipit.v
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module minipit (

always @(posedge clk) begin
if (reset) begin
counter <= 10; // TODO: don't auto-set a counter
current_count <= 0;
counter <= 16'd10; // TODO: don't auto-set a counter
current_count <= 16'd0;
r_counter_set <= 1; // TODO: don't auto-enable a default counter
divider_count <= 0;
r_interrupting <= 0;
Expand All @@ -56,7 +56,7 @@ module minipit (
current_count <= current_count;
end

if (counter_set && (current_count == counter)) begin
if (counter_set && (current_count == (counter - 1))) begin
// pull interrupt line high for one clock cycle
r_interrupting <= 1;
if (repeating) begin
Expand Down
3 changes: 0 additions & 3 deletions src/project.v
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ module tt_um_jtag_example_stevej (
assign uo_out[1] = interrupting;
assign uo_out[0] = tdo;

wire reset;
assign reset = ~rst_n;

jtag jtag0 (
.tck(ui_in[0]),
.tdi(ui_in[1]),
Expand Down
14 changes: 7 additions & 7 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ async def test_tms_five_high_for_reset(dut):
await ClockCycles(dut.clk, 1)
dut.ui_in.value = 0b0000_1000
await ClockCycles(dut.clk, 1)
dut.ui_in.value = 0b0000_1001
await ClockCycles(dut.clk, 1)
dut.ui_in.value = 0b0000_1000
await ClockCycles(dut.clk, 1)

assert dut.uo_out.value == 0x0

# Drive TMS high then low for five cycles to put us into reset.
dut._log.info("TMS high for five pulses to reset TAP controller")
dut.ui_in.value = 0b0000_1111
await ClockCycles(dut.clk, 1)
dut.ui_in.value = 0b0000_1110
await ClockCycles(dut.clk, 1)

dut.ui_in.value = 0b0000_1111
await ClockCycles(dut.clk, 1)
dut.ui_in.value = 0b0000_1110
await ClockCycles(dut.clk, 1)

dut.ui_in.value = 0b0000_1111
await ClockCycles(dut.clk, 1)

dut.ui_in.value = 0b0000_1110
await ClockCycles(dut.clk, 1)

dut.ui_in.value = 0b0000_1111
await ClockCycles(dut.clk, 1)
dut.ui_in.value = 0b0000_1110

# At this point, the design is in reset but
# the interrupt is also firing on all the other pins.
assert dut.uo_out.value == 0xFE
Expand Down

0 comments on commit ddf1203

Please sign in to comment.