descrambler: Rename unscrambled* to descrambled*

The descrambler should descramble, not unscramble.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
Sean Anderson 2022-10-16 18:53:47 -04:00
parent 2ce7dc016b
commit bd42aab5d9
2 changed files with 13 additions and 13 deletions

View File

@ -10,12 +10,12 @@ module descramble (
input [1:0] scrambled, scrambled_valid, input [1:0] scrambled, scrambled_valid,
input signal_status, test_mode, input signal_status, test_mode,
output reg locked, output reg locked,
output reg [1:0] unscrambled, unscrambled_valid output reg [1:0] descrambled, descrambled_valid
); );
reg relock, relock_next, locked_next; reg relock, relock_next, locked_next;
initial relock = 0; initial relock = 0;
reg [1:0] ldd, unscrambled_next; reg [1:0] ldd, descrambled_next;
reg [10:0] lfsr, lfsr_next; reg [10:0] lfsr, lfsr_next;
/* /*
@ -45,7 +45,7 @@ module descramble (
always @(*) begin always @(*) begin
ldd = { lfsr[8] ^ lfsr[10], lfsr[7] ^ lfsr[9] }; ldd = { lfsr[8] ^ lfsr[10], lfsr[7] ^ lfsr[9] };
unscrambled_next = scrambled ^ ldd; descrambled_next = scrambled ^ ldd;
/* /*
* We must invert scrambled before adding it to the lfsr in * We must invert scrambled before adding it to the lfsr in
@ -62,14 +62,14 @@ module descramble (
idle_counter_next = idle_counter; idle_counter_next = idle_counter;
if (scrambled_valid[1]) begin if (scrambled_valid[1]) begin
if (unscrambled_next[1] && unscrambled_next[0]) if (descrambled_next[1] && descrambled_next[0])
idle_counter_next = idle_counter - 2; idle_counter_next = idle_counter - 2;
else if (unscrambled_next[0]) else if (descrambled_next[0])
idle_counter_next = idle_counter - 1; idle_counter_next = idle_counter - 1;
else else
idle_counter_next = CONSECUTIVE_IDLES; idle_counter_next = CONSECUTIVE_IDLES;
end else if (scrambled_valid[0]) begin end else if (scrambled_valid[0]) begin
if (unscrambled_next[1]) if (descrambled_next[1])
idle_counter_next = idle_counter - 1; idle_counter_next = idle_counter - 1;
else else
idle_counter_next = CONSECUTIVE_IDLES; idle_counter_next = CONSECUTIVE_IDLES;
@ -97,21 +97,21 @@ module descramble (
end end
always @(posedge clk) begin always @(posedge clk) begin
unscrambled <= unscrambled_next; descrambled <= descrambled_next;
if (signal_status) begin if (signal_status) begin
lfsr <= lfsr_next; lfsr <= lfsr_next;
idle_counter <= idle_counter_next; idle_counter <= idle_counter_next;
relock <= relock_next; relock <= relock_next;
unlock_counter <= unlock_counter_next; unlock_counter <= unlock_counter_next;
locked <= locked_next; locked <= locked_next;
unscrambled_valid <= scrambled_valid; descrambled_valid <= scrambled_valid;
end else begin end else begin
lfsr <= 0; lfsr <= 0;
idle_counter <= CONSECUTIVE_IDLES; idle_counter <= CONSECUTIVE_IDLES;
relock <= 0; relock <= 0;
unlock_counter <= 0; unlock_counter <= 0;
locked <= 0; locked <= 0;
unscrambled_valid <= 0; descrambled_valid <= 0;
end end
end end

View File

@ -69,14 +69,14 @@ async def test_descramble(descrambler, valids):
await RisingEdge(descrambler.locked) await RisingEdge(descrambler.locked)
while descrambler.locked.value: while descrambler.locked.value:
await RisingEdge(descrambler.clk) await RisingEdge(descrambler.clk)
valid = descrambler.unscrambled_valid.value valid = descrambler.descrambled_valid.value
if valid == 0: if valid == 0:
pass pass
elif valid == 1: elif valid == 1:
outs.append(descrambler.unscrambled[1].value) outs.append(descrambler.descrambled[1].value)
else: else:
outs.append(descrambler.unscrambled[1].value) outs.append(descrambler.descrambled[1].value)
outs.append(descrambler.unscrambled[0].value) outs.append(descrambler.descrambled[0].value)
best_corr = -1 best_corr = -1
best_off = None best_off = None