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

相关推荐
upper202019 小时前
从零开始动手做Verilog实验--04--11阶FIR滤波器
fpga开发
nuoxin1141 天前
SSD201-富利威
arm开发·驱动开发·fpga开发·ffmpeg·射频工程
哄娃睡觉1 天前
FPGA、ARM、MCU、DSP的区别
fpga开发
不会武功的火柴2 天前
ModelSim入门实战(三): 批处理一键仿真与波形调试
嵌入式硬件·fpga·仿真·modelsim·ic验证·rtl
nature_forest2 天前
vivado2018.2固化程序方法之.bin文件固化法
windows·fpga开发
m0_46644103詹湛2 天前
FPGA时序优化与高速接口实战手册
笔记·学习·fpga开发·硬件架构·verilog
upper20202 天前
从零开始做Verilog实验--01--4位计数器
fpga开发
upper20202 天前
从零开始动手做Verilog实验--02--模为60的BCD加法器
fpga开发
nbwenren2 天前
基于AD9250数据接收的FPGA纯Verilog实现JESD204B协议及三套工程源码支持
fpga开发
upper20202 天前
从零开始动手做Verilog实验--03--自动售卖机
fpga开发