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

相关推荐
太空1号8 小时前
SystemVerilog小白入门3,UVM的uvm_object初体验
fpga开发
FakeOccupational12 小时前
【电路笔记 元器件】存储设备:RAM 静态随机存取存储器(SRAM)芯片+异步 SRAM 的特性+异步 SRAM读写测试(HDL)
笔记·fpga开发
嵌入式×边缘AI:打怪升级日志13 小时前
环境监测传感器从设备程序设计(ADC采集与输出控制)
单片机·嵌入式硬件·fpga开发
dadaobusi15 小时前
verilog,generate语句
fpga开发
码不停蹄Zzz1 天前
GTX DRP动态重配置技术
fpga开发
LeoZY_1 天前
CH347/339W开源项目:集SPI、I2C、JTAG、SWD、UART、GPIO多功能为一体(5)
stm32·mcu·fpga开发·开源·硬件架构·硬件工程
博览鸿蒙1 天前
FPGA 工程师如何提升自己?
fpga开发
FPGA小c鸡1 天前
FPGA Transformer加速完全指南:从模型优化到硬件实现(附实战案例)
深度学习·fpga开发·transformer
Fpga_User1 天前
项目FPGA类型获取(以xilinx为例)
fpga开发
maverick_1112 天前
【Verilog】强基础,if else 语句,以及综合RTL
fpga开发