Skip to content

Commit

Permalink
add 1 to reset
Browse files Browse the repository at this point in the history
  • Loading branch information
sameer committed Mar 1, 2021
1 parent 46bde8e commit 510f791
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/unipolar_rz.sv
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module unipolar_rz #(
output logic ready
);

localparam int TIME_COUNTER_WIDTH = $clog2($unsigned(int'($unsigned(CLOCK_RATE) * (RESET_TIME + (ONE_LOW_TIME > ZERO_LOW_TIME ? ONE_LOW_TIME : ZERO_LOW_TIME)))));
localparam int TIME_COUNTER_WIDTH = $clog2($unsigned(int'(1 + $unsigned(CLOCK_RATE) * (RESET_TIME + (ONE_LOW_TIME > ZERO_LOW_TIME ? ONE_LOW_TIME : ZERO_LOW_TIME)))));

localparam bit [TIME_COUNTER_WIDTH-1:0] PERIOD = TIME_COUNTER_WIDTH'($unsigned(CLOCK_RATE) * PERIOD_TIME - 1);
localparam bit [TIME_COUNTER_WIDTH-1:0] ZERO_LOW = TIME_COUNTER_WIDTH'($unsigned(CLOCK_RATE) * ZERO_LOW_TIME - 1);
Expand Down Expand Up @@ -84,7 +84,7 @@ begin
begin
internal_data <= 1'bx;
state <= STATE_WIDTH'(0);
time_counter <= RESET + ((INVERT ? !internal_data[0] : internal_data[0]) ? ONE_LOW : ZERO_LOW);
time_counter <= RESET + ((INVERT ? !internal_data[0] : internal_data[0]) ? ONE_LOW : ZERO_LOW) + TIME_COUNTER_WIDTH'(1);
end
end
else
Expand Down
4 changes: 3 additions & 1 deletion test/sk6805_tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module sk6805_tb (
now = $realtime;
wait (!line);
high_time = $realtime - now;
now = $realtime;
if (high_time == 600)
begin
// one
Expand All @@ -94,7 +95,8 @@ module sk6805_tb (
end
current_data = current_data + 1;
end
wait(!line);
wait(ready && clock);
assert(($realtime - now) == 80190) else $fatal("did not reset");
$finish;
end
endmodule

0 comments on commit 510f791

Please sign in to comment.