E
Evan Lavelle
Guest
There's a (very) obscure (and totally pointless?) feature in the LRM
which allows port concatenations to have mixed directions (p176):
out on some real simulators (icarus, modelsim, cver, veriwell, ISE).
Test code below.
Of these 5, one crashes, two report a syntax error, and the remaining
two appear to give the wrong answer, reporting
sreg1 data is zzzz
sreg2 data is 0101
'sreg1' should, I think, be 0101. Have I misunderstood how to do this,
or is this feature just universally ignored? Any results from other
sims?
Thanks -
Evan
------------------------------------------
module test;
reg clk, data;
wire [3:0] sreg1, sreg2;
mixed_direction m1(.clk(clk), .p({data, sreg1}));
sreg m2(.clk(clk), .a(data), .e(sreg2));
initial
main;
task main;
integer i;
begin
clk = 0;
for(i=0; i<4; i=i+1) begin
data = i;
#1 clk = 1;
#1 clk = 0;
end
$display("sreg1 data is %b", sreg1);
$display("sreg2 data is %b", sreg2);
end
endtask
endmodule
// the test module: the second port has a mixed direction
module mixed_direction (clk, .p({a, e}));
input clk;
input a;
output e;
reg [3:0] e;
always @(posedge clk)
e <= {e[2:0], a};
endmodule
// the sanity check module: this is identical to 'mixed_direction',
// but has a simpler port list
module sreg (clk, a, e);
input clk;
input a;
output e;
reg [3:0] e;
always @(posedge clk)
e <= {e[2:0], a};
endmodule
which allows port concatenations to have mixed directions (p176):
I flagged this as an error in my translator, and I've just tried itmodule mixed_direction (.p({a, e}));
input a; // p contains both input and output directions.
output e;
out on some real simulators (icarus, modelsim, cver, veriwell, ISE).
Test code below.
Of these 5, one crashes, two report a syntax error, and the remaining
two appear to give the wrong answer, reporting
sreg1 data is zzzz
sreg2 data is 0101
'sreg1' should, I think, be 0101. Have I misunderstood how to do this,
or is this feature just universally ignored? Any results from other
sims?
Thanks -
Evan
------------------------------------------
module test;
reg clk, data;
wire [3:0] sreg1, sreg2;
mixed_direction m1(.clk(clk), .p({data, sreg1}));
sreg m2(.clk(clk), .a(data), .e(sreg2));
initial
main;
task main;
integer i;
begin
clk = 0;
for(i=0; i<4; i=i+1) begin
data = i;
#1 clk = 1;
#1 clk = 0;
end
$display("sreg1 data is %b", sreg1);
$display("sreg2 data is %b", sreg2);
end
endtask
endmodule
// the test module: the second port has a mixed direction
module mixed_direction (clk, .p({a, e}));
input clk;
input a;
output e;
reg [3:0] e;
always @(posedge clk)
e <= {e[2:0], a};
endmodule
// the sanity check module: this is identical to 'mixed_direction',
// but has a simpler port list
module sreg (clk, a, e);
input clk;
input a;
output e;
reg [3:0] e;
always @(posedge clk)
e <= {e[2:0], a};
endmodule