Looking to create a pseudo-random sequence generator similar to the Linear Feedback Shift Register, but in JavaScript due to familiarity with the language, and using HTML for the GUI interface. The user will input an initial value to receive a schematic diagram and the generated pseudo-random sequence.
var UserInput = document.getElementById('input');
var Output = document.getElementById('output');
// Array of objects containing circuit images and tap configurations required for shift registers
function generateSequence(){
var data = [
{
image:"pic/2bit.png",
tap:[0,1]
},
...
...
// List of circuit configurations
];
var first = UserInput.value.split("");
for (k=0; k<first.length; k++) {
first[k] = +first[k];
}
var bit = first.length - 2;
var matrix = [first];
var t = 0;
var between;
var z;
for (i=1; i<Math.pow(2, bit+2)-1; i++){
for (j=0; j<data[bit].tap.length; j++){
z = data[bit].tap[j];
t = t ^ matrix[i-1][z];
}
between = matrix[i-1];
console.log(between);
between.unshift(t);
between.pop();
matrix[i] = between;
t = 0;
}
console.log(matrix);
}
You can access the HTML code here.
The issue lies in that while console.log(between);
displays the last generated row correctly, console.log(matrix)
overwrites all rows by the last one. Expected output should be:
101
010
001
100
110
111
011
Instead, it currently shows:
011
011
011 ...
The solution is still incomplete and does not display in HTML. Additional work is needed to extract the pseudo-random sequence from the final matrix column.