移位寄存器使用
/*
邊緣檢測(cè)、濾波等相關(guān)模板的移位寄存器
假設(shè)在rom中文件夾下以wod中的數(shù)據(jù)存放,列加行的值作為該 數(shù)的地址
現(xiàn)在每次取出3列數(shù)據(jù)為一組,如第一列abc,第二例def,第三列g(shù)hi
使用shifter_register ip核來(lái)實(shí)現(xiàn)這種功能,可以利用這種方法實(shí)現(xiàn)流水線操作
*/
?
module left_right_register(input clk,input rst_n,output [7:0] shiftout0,output [7:0] shiftout1,output [7:0] shiftout2 ); wire shift_en; wire [7:0] cnt; wire [7:0] in; counter counter(.clk(clk),.rst_n(rst_n),.shift_en(shift_en),//輸出使能信號(hào).cnt(cnt)//給rom地址信號(hào) ); my_rom my_rom(.address(cnt),.clock(clk),.q(in)); shift_register shift_register(.clk(clk),.rst_n(rst_n),.in(in),. shift_en(shift_en),.shiftout0(shiftout0),.shiftout1(shiftout1),.shiftout2(shiftout2) );endmodule?
module counter(input clk,input rst_n,output reg shift_en,output reg [7:0]cnt);always@(posedge clk or negedge rst_n)if(!rst_n)begincnt<=0;shift_en<=0;endelse beginif(cnt>=16)//表示移位寄存器中的兩個(gè)fifo值已經(jīng)移入begincnt<=cnt+1;shift_en<=1;endelsecnt<=cnt+1;endendmodule?
module shift_register(input clk,input rst_n,input [7:0] in,output shift_en,output [7:0] shiftout0,output [7:0] shiftout1,output [7:0] shiftout2 );wire [15:0] taps; assign shiftout0=shift_en?in:0; assign shiftout1=shift_en?taps[7:0]:0; assign shiftout2=shift_en?taps[15:8]:0;my_shift my_shift(.clock(clk),.shiftin(in),//rom提供的初始數(shù)據(jù).shiftout(),.taps(taps));?
總結(jié)
- 上一篇: 总结:K8s之HPA
- 下一篇: arduino声音传感器与二极管_怎样使