先说结论: 方法二repeat当时,test1d比方法一晚1个时钟周期变成1。 原因是: 首先方法一、二都定义了时钟周期为20ns。 方法一,在第90ns,test从0变1。在第100ns,也就是第5个时钟周期,test1d也会从0变成1。 而 ...
`timescale 1ns / 1ps module max_tb(); //输入 reg clk; reg [7:0] a,b,c; //输出 wire [7:0] max_o; //信号初始化 initial begin clk = 1\'b0 a = 8\'b0; b = 8\'b0; c = 8\'b0 ...
`timescale 1ns / 1ps initial clk=0; always #10 clk=~clk;
`timescale 1ns / 1ps initial begin reset = 1; #20 reset = 0; end
`timescale 1ns / 1ps initial begin reset = 1; #20 reset = 0; end
function [x:0] max_val; input [x:0] a,b,c; begin max_val = a>b ? (a>c ? a : c) : (b>c ? b : c); end endfounction
(1)big_vect[3+:8] = 8\'b1100_0111; (2)big_vect[15-:8] = 8\'b1100_0110; (3)little_vect[3+:8] = 8\'b0011_0001; (4)little_vect[15-:8] = 8\'b0011_1001;
`define SIMULATION `ifdef SIMULATION parameter CLK_PRE = 500; `else parameter CLK_PRE = 50000000; `endif
module sub_module ( input clk, // 其他输入输出 ); parameter CLK_FRE = 50000000; // 50MHz // 其他逻辑和代码 endmodule module top_module ( input clk, // 其 ...
#define CLK_FRE 50000000UL // 50 MHz
case (dig) 4\'b0000 : seg <= 8\'b1000_0001; 4\'b0001 : seg <= 8\'b1100_1111; 4\'b0010 : seg <= 8\'b1001_0010; 4\'b0011 : seg ...
B(不能数字开头,需要字母或下划线开头)
if (test_in) test_in_cnt <= test_in_cnt + 1\'b1; else test_in_cnt <= test_in_cnt;
reg [7:0] ram[31:0];
reg signal_1d; always@(posedge clk) begin signal_1d <= signal; end reg flag; always@(posedge clk or negedge rst_n) begin if(!rst_n) flag <= 1\'b0; else if((signal==1\'b1)&&(si ...