[HDLBits] Rule90

Rule 90 is a one-dimensional cellular automaton with interesting properties.

The rules are simple. There is a one-dimensional array of cells (on or off). At each time step, the next state of each cell is the XOR of the cell's two current neighbours. A more verbose way of expressing this rule is the following table, where a cell's next state is a function of itself and its two neighbours:

Left Center Right Center's next state
1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 1
0 1 1 1
0 1 0 0
0 0 1 1
0 0 0 0

(The name "Rule 90" comes from reading the "next state" column: 01011010 is decimal 90.)

In this circuit, create a 512-cell system (q[511:0]), and advance by one time step each clock cycle. The load input indicates the state of the system should be loaded with data[511:0]. Assume the boundaries (q[-1] and q[512]) are both zero (off).

复制代码
module top_module(
    input clk,
    input load,
    input [511:0] data,
    output [511:0] q ); 
    always@(posedge clk) begin
        if(load)
            q<=data;
        else
            q<={1'b0,q[511:1]}^{q[510:0],1'b0};
        //verilog最好的地方就是支持整个数组批量运算
    end
endmodule

verilog真舒服

相关推荐
尤老师FPGA2 小时前
DDR4系列之ECC功能(六)
fpga开发·ddr4
Terasic友晶科技2 小时前
3-基于FPGA开发板OSK/TSP/C5P的串口通信设计 (CP2102N)
fpga开发·串口·uart·tsp·c5p·osk
gouqu51562 小时前
FPGA开发编译
fpga开发
GilgameshJSS2 小时前
STM32H743-ARM例程43-SD_IAP_FPGA
arm开发·stm32·fpga开发
FPGA_小田老师2 小时前
FPGA语法基础(三):Verilog 位选择语法详解
fpga开发·verilog语法·verilog位选择
坏孩子的诺亚方舟2 小时前
FPGA系统架构设计实践5_IP的封装优化
fpga·vivado·rqs·工程质量
坏孩子的诺亚方舟6 小时前
FPGA系统架构设计实践4_SelectIO
fpga·xilinx·selectio
XINVRY-FPGA17 小时前
XC95288XL-10TQG144I Xilinx AMD CPLD
arm开发·单片机·嵌入式硬件·mcu·fpga开发·硬件工程·fpga
i道i19 小时前
Verilog 利用伪随机,时序,按键消抖等,实现一个(打地鼠)游戏
游戏·fpga开发·verilog
奋斗的牛马21 小时前
OFDM理解
网络·数据库·单片机·嵌入式硬件·fpga开发·信息与通信