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

相关推荐
第二层皮-合肥13 小时前
高速采集卡FPGA设计方案及代码
fpga开发
Runner.DUT15 小时前
详解赛灵思SRIO IP并提供一种FIFO封装SRIO的收发控制器仿真验证
fpga开发
嵌入式-老费16 小时前
再谈fpga开发(fpga调试方法)
fpga开发
千宇宙航17 小时前
闲庭信步使用图像验证平台加速FPGA的开发:第三十三课——车牌识别的FPGA实现(5)车牌字符的识别
自动化·fpga·modelsim·车牌识别·仿真测试平台
XINVRY-FPGA20 小时前
XCZU4EV-1FBVB900E Xilinx FPGA AMD Zynq UltraScale+ MPSoC EV(Embedded Vision)
arm开发·嵌入式硬件·计算机视觉·fpga开发·硬件架构·硬件工程·fpga
从今天开始学习Verilog20 小时前
FFT算法实现之fft IP核
算法·fpga开发
Turing_kun1 天前
基于FPGA的SPI控制FLASH读写
fpga开发
hahaha60161 天前
差模干扰 & 共模干扰
fpga开发
璞致电子2 天前
【PZ-KU060-KFB】——Kintex UltraScale 纯 FPGA 开发平台,释放高速并行计算潜能,高性价比的 FPGA 解决方案
fpga开发·fpga
我爱C编程2 天前
基于FPGA的16QAM软解调+卷积编码Viterbi译码通信系统,包含帧同步,信道,误码统计,可设置SNR
fpga开发·16qam·软解调·帧同步·卷积编码·viterbi译码