assign
声明用于驱动wire
s。
如果你已经声明一个reg
,那么你必须在程序中给它赋值(always
或initial
块)。最好的做法是只在相同的always
块中设置reg
的值。例如:
always @(*) begin // combo logic block
if(some_condition) begin
icache_ram_rw = 1'b0;
end else begin
icache_ram_rw = something_else;
end
有reg
S和wire
s表示你应该读了之间的重要区别。
我有一种感觉,虽然你需要一些时钟逻辑,如果你正在驾驶RAM信号。在这种情况下,你需要的代码看起来是这样的:
// some parameter definitions to make logic 'read' clearer.
localparam READ = 1'b0;
localparam WRITE = 1'b1;
// standard clocked logic 'template' that synthesis tools recognise.
always @(posedge clk or negedge resetb)
if(!resetb) begin // asynchronous active low reset
icache_ram_rw <= READ;
end else if(some_enable_condition) begin
icache_ram_rw <= WRITE;
end else begin
icache_ram_rw <= READ;
end
感谢您的完整答案!钟控逻辑的确出现在赋值中,为了简单起见,我在这里省略了它(原来可能最好添加它)= D – 2009-12-08 14:49:11