设计以下两个模块的顶层模块 module lsd(clk,rst_n,led); input clk,rst_n; output reg [3:0] led; reg [25:0] cnt; reg clk_2s; always @ (posedge clk or negedge rst_n) if (!rst_n) begin cnt <='d0; clk_2s <= 0; end else if (cnt == 26'd24_999_999) begin cnt <= 0; clk_2s <= ~clk_2s; end else cnt <= cnt + 1'b1; always @ (posedge clk_2s or negedge rst_n) if (!rst_n) led <= 4'b0111; else led <= {led[0],led[3:1]}; endmodule module aa(clk,sel,rst_n,seg,Q); input clk,rst_n,Q; output reg [2:0]sel; output reg [6:0]seg; reg [25:0]cnt; reg clk_n; always @(posedge clk_n) begin if(rst_n==0) sel <= 3'd0; else begin if(sel < 3'd6) sel <= sel+1'b1; else sel <= 3'd0; end end always @(posedge clk) begin if(cnt==26'd99_999) begin cnt <= 0; clk_n <= ~clk_n; end else cnt <= cnt+1'b1; end always @(Q or sel) begin if(Q==0) seg <= 7'b1000000; else case(sel) 3'b000 : seg <= 7'b1111001; 3'b001 : seg <= 7'b0100100; 3'b010 : seg <= 7'b0110000; 3'b011 : seg <= 7'b0011001; 3'b100 : seg <= 7'b0010010; 3'b101 : seg <= 7'b0000010; default seg <=7'b1111111; endcase end endmodule
时间: 2024-03-11 08:43:56 浏览: 114
SPI模块顶层模块设计
这里有两个模块的顶层模块,其中一个是 lsd 模块,另一个是 aa 模块。lsd 模块是一个计数器,每秒钟会将 led 显示的值向左移动一位,而 aa 模块则是根据输入的 Q 和 sel 信号来控制七段数码管的显示。其中 sel 信号是控制七段数码管显示哪一位数字的信号,而 Q 信号是控制显示的数字的信号。在每秒钟的计数到 99_999 时,会将 clk_n 信号取反,从而控制 lsd 模块中的 led 显示向左移动一位。
阅读全文