/*************************** * diskRW.v * Test code for reading/writing a simulated * disk image. NB--So far as I can tell, the only * input mechanism available in iverilog is * text-based readmemb(). * ***************************/ module foo(); reg[3:0] ch[0:1]; integer fd; integer i; initial begin $readmemb( "disk-0/block-0-0-0.txt", ch ); fd = $fopen( "disk-0/block-0-0-0.txt" , "w"); i = 0; ch[i] = ch[i] & 4'b0111; $fwrite(fd, "%b\n", ch[i] ); i = 1; ch[i] = ch[i] & 4'b0001; $fwrite(fd, "%b\n", ch[i] ); $fclose(fd); $finish; end endmodule /* foo */