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

相关推荐
li星野3 小时前
打工人日报#20251009
fpga开发
cycf3 小时前
Vivado 时序约束的完整作战地图(二)
fpga开发
cycf4 小时前
时钟周期约束(三)
fpga开发
szxinmai主板定制专家4 小时前
RK3588+AI算力卡替代英伟达jetson方案,大算力,支持FPGA自定义扩展
arm开发·人工智能·分布式·fpga开发
ARM+FPGA+AI工业主板定制专家5 小时前
基于NVIDIA ORIN+FPGA+AI自动驾驶硬件在环注入测试
人工智能·fpga开发·机器人·自动驾驶
bnsarocket6 小时前
Verilog和FPGA的自学笔记4——多路选择器(always语句)
笔记·fpga开发·编程·verilog·自学·硬件编程
爱吃汽的小橘6 小时前
使用乒乓ram去直流分量
fpga开发
技术小白爱FPGA7 小时前
Altera Fpga PCI master 设计
fpga开发
爱吃汽的小橘1 天前
异步串口通信和逻辑分析仪
运维·服务器·网络·单片机·嵌入式硬件·fpga开发
bnsarocket1 天前
Verilog和FPGA的自学笔记3——仿真文件Testbench的编写
笔记·fpga开发·verilog·自学