|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 frankjintao 于 2012-12-11 21:16 编辑
DE1的开发板有个LED灯控PWM IP核实验。在PWM核中,有个always的敏感信号是psedge CLK时,描述语句中的左边的寄存器被“="赋值成什么电路?而且该描述语句怎么可以用"="给左边的寄存器赋值呢。按照常理来说,如果敏感信号一般是输入电平信号,描述语句应该采用“=”语句的呀?如果敏感信号是CLK,应该用"<="赋值。哪位大侠能解释下。以下是程序
module pwn(clk,
reset_n,
chipselect,
address,
write,
writedata,
read,
byteenable,
readdata,
PWM_out);
input clk;
input reset_n;
input chipselect;
input [1:0]address;
input write;
input [31:0] writedata;
input read;
input [3:0] byteenable;
output [31:0] readdata;
output PWM_out;
reg [31:0] clock_divide_reg; //Internal register clock divide
reg [31:0] duty_cycle_reg; //Internal register ;the clock less than duty_cycle_reg pwm_out will be output 1.otherwise will be 0
reg control_reg;
reg clock_divide_reg_selected;
reg duty_cycle_reg_selected;
reg control_reg_selected;
reg [31:0] PWM_counter;
reg [31:0] readdata;
reg PWM_out;
wire pwm_enable;
always @ (address)
begin
clock_divide_reg_selected<=0;
duty_cycle_reg_selected<=0;
control_reg_selected<=0;
case(address)
2'b00:clock_divide_reg_selected<=1;
2'b01:duty_cycle_reg_selected<=1;
2'b10:control_reg_selected<=1;
default:
begin
clock_divide_reg_selected<=0;
duty_cycle_reg_selected<=0;
control_reg_selected<=0;
end
endcase
end
always @ (posedge clk or negedge reset_n)
begin
if(reset_n==1'b0)
clock_divide_reg=0;
else
begin
if(write & chipselect & clock_divide_reg_selected)
begin
if(byteenable[0])
clock_divide_reg[7:0]=writedata[7:0];
if(byteenable[1])
clock_divide_reg[15:8]=writedata[15:8];
if(byteenable[2])
clock_divide_reg[23:16]=writedata[23:16];
if(byteenable[3])
clock_divide_reg[31:24]=writedata[31:24];
end
end
end
always @ (posedge clk or negedge reset_n)
begin
if(reset_n==1'b0)
duty_cycle_reg=0;
else
begin
if(write & chipselect & duty_cycle_reg_selected)
begin
if(byteenable[0])
duty_cycle_reg[7:0]=writedata[7:0];
if(byteenable[1])
duty_cycle_reg[15:8]=writedata[15:8];
if(byteenable[2])
duty_cycle_reg[23:16]=writedata[23:16];
if(byteenable[3])
duty_cycle_reg[31:24]=writedata[31:24];
end
end
end
always @ (posedge clk or negedge reset_n)
begin
if(reset_n==1'b0)
control_reg=0;
else
begin
if(write & chipselect & control_reg_selected)
begin
if(byteenable[0])
control_reg=writedata[0];
end
end
end
最后3个always中的描述语句怎么用的是”=“语句赋值。高步懂。
我知道always行为描述的2输入与门电路,等等
input a,b;
output reg out;
alwys @(a or b)
begin out=a&b;end//不是”<=“赋值。 |
-
-
pwm.rar
841 Bytes, 下载次数: 3
, 下载积分:
资产 -2 信元, 下载支出 2 信元
|