OpenCores
URL https://opencores.org/ocsvn/rc4-prbs/rc4-prbs/trunk

Subversion Repositories rc4-prbs

[/] [rc4-prbs/] [trunk/] [rc4.v] - Diff between revs 8 and 10

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 8 Rev 10
Line 16... Line 16...
 You should have received a copy of the GNU Lesser General Public
 You should have received a copy of the GNU Lesser General Public
 License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/
*/
 
 
 
 
`include "rc4.inc"
`include "/home/alfred/docto/FPGADesign/rc4-prbs/trunk/rc4.inc"
 
 
module rc4(clk,rst,output_ready,password_input,K);
module rc4(clk,rst,output_ready,password_input,K);
 
 
input clk; // Clock
input clk; // Clock
input rst; // Reset
input rst; // Reset
Line 38... Line 38...
 
 
// Key
// Key
reg [7:0] key[0:`KEY_SIZE-1];
reg [7:0] key[0:`KEY_SIZE-1];
// S array
// S array
reg [7:0] S[0:256];
reg [7:0] S[0:256];
 
reg [9:0] discardCount;
 
 
// Key-scheduling state
// Key-scheduling state
`define KSS_KEYREAD 4'h0
`define KSS_KEYREAD 4'h0
`define KSS_KEYSCHED1 4'h1
`define KSS_KEYSCHED1 4'h1
`define KSS_KEYSCHED2 4'h2
`define KSS_KEYSCHED2 4'h2
Line 108... Line 109...
                                if (i == 8'hFF)
                                if (i == 8'hFF)
                                        begin
                                        begin
                                        KSState <= `KSS_CRYPTO;
                                        KSState <= `KSS_CRYPTO;
                                        i <= 8'h01;
                                        i <= 8'h01;
                                        j <= 8'h00;
                                        j <= 8'h00;
 
                                        discardCount <= 10'h0;
                                        end
                                        end
                                else    begin
                                else    begin
                                        i <= i + 1;
                                        i <= i + 1;
                                        KSState <= `KSS_KEYSCHED2;
                                        KSState <= `KSS_KEYSCHED2;
                                        end
                                        end
Line 134... Line 136...
                                end
                                end
                `KSS_CRYPTO2: begin
                `KSS_CRYPTO2: begin
                                S[i] <= S[j];
                                S[i] <= S[j];
                                S[j] <= S[i]; // We can do this because of verilog.
                                S[j] <= S[i]; // We can do this because of verilog.
                                K <= S[ S[i]+S[j] ];
                                K <= S[ S[i]+S[j] ];
                                output_ready <= 1; // Valid K at output
                                if (discardCount<1000)
 
                                        discardCount<=discardCount+1;
 
                                else    output_ready <= 1; // Valid K at output
                                i <= i+1;
                                i <= i+1;
                                KSState <= `KSS_CRYPTO;
                                KSState <= `KSS_CRYPTO;
                                end
                                end
                default:        begin
                default:        begin
                                end
                                end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.