Rule110

Rule 110 is a one-dimensional cellular automaton with interesting properties (such as being Turing-complete).

There is a one-dimensional array of cells (on or off). At each time step, the state of each cell changes. In Rule 110, the next state of each cell depends only on itself and its two neighbours, according to the following table:

Rule110_第1张图片

 

module top_module(
    input clk,
    input load,
    input [511:0] data,
    output [511:0] q
); 
    wire [511:0] left_data;
    wire [511:0] right_data;
    
    assign left_data = {q[510:0], 1'b0};
    assign right_data =  {1'b0, q[511:1]};
    
    always@ (posedge clk)
        if(load)
            q <= data;
    	else
            q <= (q & ~left_data) | (~right_data & left_data) | (~q & left_data);
        
        
endmodule

你可能感兴趣的:(HDLBits题目,verilog)