[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真舒服

相关推荐
tobias.b2 小时前
408真题解析-2010-12-计组-程序执行时间
单片机·嵌入式硬件·fpga开发·计算机考研·408真题解析
洋洋Young9 小时前
【Xilinx FPGA】7 Series 收发器架构与时钟设计
fpga开发·xilinx
unicrom_深圳市由你创科技9 小时前
XDMA 技术及在 Windows 平台的应用实践
fpga开发
s09071361 天前
【Agent】Claude code辅助verilog编程
fpga开发
3有青年1 天前
altera fpga agilex 5 连接到HVIO BANK上的参考时钟,是否可以作为HSIO BANK内部IOPLL的输入时钟
fpga开发
FPGA_ADDA1 天前
基于ZU47DR 的高性能射频卡
fpga开发
ooo-p1 天前
FPGA学习篇——Verilog学习之“流水灯”
学习·fpga开发
坏孩子的诺亚方舟1 天前
FPGA系统架构设计实践14_OTA升级
fpga·加载
FPGA小c鸡1 天前
【FPGA视频处理】帧缓冲设计完全指南:从单缓冲到三缓冲的深度解析与实战应用
fpga开发·音视频
hexiaoyan8271 天前
【无标题】高速信号处理设计原理图:413-基于双XCVU9P+C6678的100G光纤加速卡
fpga开发·高速信号处理·光纤加速·xcvu9p芯片·硬件加速卡