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

相关推荐
珞光电子USRP SDR软件无线电平台14 小时前
打破通用瓶颈:珞光电子发布 Luowave Driver V2 定制化驱动方案
fpga开发
9527华安14 小时前
FPGA实现PCIe数据通信培训课程,提供工程源码+视频教程+FPGA开发板
fpga开发·pcie·视频教程·培训
my_daling14 小时前
FPGA实现IIC主机读写,以及部分IIC传感器控制流程
fpga开发
乌恩大侠14 小时前
【AI-RAN】在空ubuntu服务器安装环境和生成TV,高达430G文件
服务器·人工智能·ubuntu·fpga开发·o-ru
qq_1508419916 小时前
高云FPGA固件下载速成
fpga开发
一个平凡而乐于分享的小比特16 小时前
一文读懂MCU与FPGA:核心区别、协同之道与双修秘籍
单片机·fpga开发·职场发展·mcu开发
LCMICRO-1331084774620 小时前
长芯微LD1871完全P2P替代AD1871,是一款立体声音频ADC
单片机·嵌入式硬件·fpga开发·音视频·硬件工程·dsp开发·音频adc
木心术121 小时前
AI在FPGA中实现多平台射频信号时隙调整参考及案例
人工智能·fpga开发·信息与通信
LCMICRO-1331084774621 小时前
长芯微LD73360完全P2P替代AD73360,是一款工业电能计量6通道模拟输入前端(AFE) 处理器
stm32·单片机·嵌入式硬件·fpga开发·硬件工程·模拟前端afe
zjxtxdy1 天前
STM32开发
stm32·单片机·fpga开发