• 移位寄存器使用


    /*
    边缘检测、滤波等相关模板的移位寄存器
    假设在rom中文件夹下以wod中的数据存放,列加行的值作为该 数的地址
    现在每次取出3列数据为一组,如第一列abc,第二例def,第三列ghi
    使用shifter_register ip核来实现这种功能,可以利用这种方法实现流水线操作

    */

     

    1. module left_right_register(
    2. input clk,
    3. input rst_n,
    4. output [7:0] shiftout0,
    5. output [7:0] shiftout1,
    6. output [7:0] shiftout2
    7. );
    8. wire shift_en;
    9. wire [7:0] cnt;
    10. wire [7:0] in;
    11. counter counter(
    12. .clk(clk),
    13. .rst_n(rst_n),
    14. .shift_en(shift_en),//输出使能信号
    15. .cnt(cnt)//给rom地址信号
    16. );
    17. my_rom my_rom(
    18. .address(cnt),
    19. .clock(clk),
    20. .q(in)
    21. );
    22. shift_register shift_register(
    23. .clk(clk),
    24. .rst_n(rst_n),
    25. .in(in),
    26. . shift_en(shift_en),
    27. .shiftout0(shiftout0),
    28. .shiftout1(shiftout1),
    29. .shiftout2(shiftout2)
    30. );
    31. endmodule

     

    1. module counter(
    2. input clk,
    3. input rst_n,
    4. output reg shift_en,
    5. output reg [7:0]cnt
    6. );
    7. always@(posedge clk or negedge rst_n)
    8. if(!rst_n)
    9. begin
    10. cnt<=0;
    11. shift_en<=0;
    12. end
    13. else begin
    14. if(cnt>=16)//表示移位寄存器中的两个fifo值已经移入
    15. begin
    16. cnt<=cnt+1;
    17. shift_en<=1;
    18. end
    19. else
    20. cnt<=cnt+1;
    21. end
    22. endmodule

     

    1. module shift_register(
    2. input clk,
    3. input rst_n,
    4. input [7:0] in,
    5. output shift_en,
    6. output [7:0] shiftout0,
    7. output [7:0] shiftout1,
    8. output [7:0] shiftout2
    9. );
    10. wire [15:0] taps;
    11. assign shiftout0=shift_en?in:0;
    12. assign shiftout1=shift_en?taps[7:0]:0;
    13. assign shiftout2=shift_en?taps[15:8]:0;
    14. my_shift my_shift(
    15. .clock(clk),
    16. .shiftin(in),//rom提供的初始数据
    17. .shiftout(),
    18. .taps(taps)
    19. );

     

  • 相关阅读:
    git使用
    深度剖析C语言指针笔试题 Ⅱ
    手撕 LFU 缓存
    SVM学习笔记
    2 分钟,教你用 Serverless 每天给女朋友自动发土味情话
    C#修改默认参数settings文件
    拯救者Legion Y9000K 2021H(82K6)原厂oem预装Win11系统镜像
    Nginx正向代理配置(http)
    2015架构真题(五十)
    2023年中国工业炉分类、产量及市场规模分析[图]
  • 原文地址:https://blog.csdn.net/weixin_43533751/article/details/125491722