在verilog里, 上升沿和下降沿的问题. 求大神帮助, 小的新人一枚. 谢谢先
我的时间j变化时,a和r也应该跟着变化,但当j在第二次变化的时候,a和r没有跟着变,我的代码和testbench如下,并附有我的真图.moduletry(clk,rst,...
我的时间j变化时, a和r也应该跟着变化, 但当j 在第二次变化的时候, a和r 没有跟着变, 我的代码和testbench如下,并附有我的真图.
module try ( clk, rst, v, j, a, r, b);
input wire clk;
input wire rst;
input wire [9:0] v;
input wire [3:0] j;
output reg [1:0] r;
reg [9:0] v_call;
output reg [9:0] a;
output reg [9:0] b;
always @ (*)
if (j == 0) begin
v_call = v;
b = v_call;
end
always @ (posedge j or negedge j) begin
r[1] = v_call[9];
r[0] = v_call[8];
v_call = v_call << 2;
a = v_call;
end
endmodule
testbench如下:
`timescale 1ns/100ps
module testbench1 ();
reg clk;
reg rst;
//wire pbit;
reg [9:0] v;
reg [3:0] j;
wire [1:0] r;
wire [9:0] a;
wire [9:0] b;
//wire [3:0] c;
//wire [2:0] d;
try DUT (
.clk(clk),
.rst(rst),
//.pbit(pbit),
.v(v),
.j(j),
.r(r),
.a(a),
.b(b)
//.c(c),
//.d(d)
);
initial begin
v = 10'b1110001011;
clk = 0;
rst = 0;
j = 4'd0;
#5
rst = 1;
#5
clk <= 1; // S = 01
#10
clk <= 0;// S = 10
#10
clk <= 1; // S = 11
#10
clk <= 0;// S = 00
j = 4'd1;
#10
clk <= 1; //01
#10
clk <= 0; //10
#10
clk <= 1; //11
#10
clk <= 0;// S = 00
j = 4'd2;
#10
clk <= 1; //01
#10
clk <= 0; //10
#10
clk <= 1; //11
#10
clk <= 0;// S = 00
j = 4'd3;
#10
clk <= 1; //01
#10
clk <= 0; //10
#10
clk <= 1; //11
end
endmodule 展开
module try ( clk, rst, v, j, a, r, b);
input wire clk;
input wire rst;
input wire [9:0] v;
input wire [3:0] j;
output reg [1:0] r;
reg [9:0] v_call;
output reg [9:0] a;
output reg [9:0] b;
always @ (*)
if (j == 0) begin
v_call = v;
b = v_call;
end
always @ (posedge j or negedge j) begin
r[1] = v_call[9];
r[0] = v_call[8];
v_call = v_call << 2;
a = v_call;
end
endmodule
testbench如下:
`timescale 1ns/100ps
module testbench1 ();
reg clk;
reg rst;
//wire pbit;
reg [9:0] v;
reg [3:0] j;
wire [1:0] r;
wire [9:0] a;
wire [9:0] b;
//wire [3:0] c;
//wire [2:0] d;
try DUT (
.clk(clk),
.rst(rst),
//.pbit(pbit),
.v(v),
.j(j),
.r(r),
.a(a),
.b(b)
//.c(c),
//.d(d)
);
initial begin
v = 10'b1110001011;
clk = 0;
rst = 0;
j = 4'd0;
#5
rst = 1;
#5
clk <= 1; // S = 01
#10
clk <= 0;// S = 10
#10
clk <= 1; // S = 11
#10
clk <= 0;// S = 00
j = 4'd1;
#10
clk <= 1; //01
#10
clk <= 0; //10
#10
clk <= 1; //11
#10
clk <= 0;// S = 00
j = 4'd2;
#10
clk <= 1; //01
#10
clk <= 0; //10
#10
clk <= 1; //11
#10
clk <= 0;// S = 00
j = 4'd3;
#10
clk <= 1; //01
#10
clk <= 0; //10
#10
clk <= 1; //11
end
endmodule 展开
2015-02-28
展开全部
j又不是时钟,而且4bit宽度,只有单bit的在0和1变化时,才有上升沿和下降沿的说法,你的j在1,2,3,4这样变化,那叫你说,怎么才叫做上升沿,怎么叫做下降沿?你学verilog,不会连时钟是干啥的都不知道吧?
追问
我自学的... 我想我懂了,谢谢
希卓
2024-10-17 广告
2024-10-17 广告
分布式应变监测技术是现代结构健康监测的重要组成部分。它通过在结构内部或表面布置多个应变传感器,实现对结构变形和应变的连续、实时监测。这种技术能够准确捕捉结构在各种载荷和环境条件下的应变响应,为结构的安全评估、损伤预警和寿命预测提供重要数据支...
点击进入详情页
本回答由希卓提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询