`define Print_Port_Address 16'he7c9 //SH2
`define Print_CAHR_Port_Address 16'hdfe8
`define Print_INT_Port_Address 16'he7cc //First ADDRESS
`define Print_LONG_Port_Address 16'hdfec //First ADDRESS
task Cprint;// String OUT until the byte 00 or xx detected with least Byte first and justified.
integer i;
begin :Block
i=0;
while (1) begin
if (char_buffer[i*8 +:8] ===8'h00 || char_buffer[i*8 +:8]===8'hxx) begin
disable Block;
end
$write("%c",char_buffer[i*8 +:8]);
i=i+1;
end
end
endtask
reg [0:639] char_buffer;
integer counter=0;
reg flag=0; //Jan.31.2004 To address multi-cycle write for BYTE and WORD
always @ (posedge CLK ) begin
if ((WE === 1'b1) && !flag) begin//Jan.31.2004
if (ADR[15:0]==`Print_Port_Address) begin
flag=1;
if (DATI[15: 8]===8'h00) begin
char_buffer[counter*8 +:8]=DATI[15: 8];
if (char_buffer[0 +:8*7]==="$finish") begin
$stop;
end else if (char_buffer[0 +:8*5]==="$time") begin
$display("Current Time on Simulation=%d",$time);
end else Cprint;//$write("%s",char_buffer);
for (counter=0; counter< 80; counter=counter+1) begin
char_buffer[counter*8 +:8]=8'h00;
end
counter=0;
end else begin
char_buffer[counter*8 +:8]=DATI[15: 8];
counter=counter+1;
end
end
else if (ADR[15:0]==`Print_CAHR_Port_Address ) begin
flag=1;
$write("%h ",DATI[7: 0]);
end else if (ADR[15:0]==`Print_INT_Port_Address) begin
flag=1;
#10 $write("%h ",DATI[15:0]);//Little Endian
end else if (ADR[15:0]==`Print_LONG_Port_Address) begin
#10 $write("%h ",DATI[31:0]);//Big Endian
end
end //if
else if (!WE) flag=0;//Jan.31.2004
end //always
|