问题描述
只读存储器ROM有一个32位的地址输入端a,用于输入存储单元地址;
一个32位的数据输出端inst,用于输出指令。
根据提示,在右侧编辑器补充代码,设计一个按字节编址的有32位地址输入端和32位数据输出端的指令存储器,其中从地址0开始存放的32条MIPS指令如下所示。
MIPS指令(16进制)
3c010000
34240050
20050004
0c000018
ac820000
8c890000 等。
代码
module scinstmem (a,inst);
input [31:0] a;
output [31:0] inst;
//begin
wire [31:0] rom [0:31];
assign rom[5'h00] = 32'h3c010000;
assign rom[5'h01] = 32'h34240050;
assign rom[5'h02] = 32'h20050004;
assign rom[5'h03] = 32'h0c000018;
assign rom[5'h04] = 32'hac820000;
assign rom[5'h05] = 32'h8c890000;
assign rom[5'h06] = 32'h01244022;
assign rom[5'h07] = 32'h20050003;
assign rom[5'h08] = 32'h20a5ffff;
assign rom[5'h09] = 32'h34a8ffff;
assign rom[5'h0A] = 32'h39085555;
assign rom[5'h0B] = 32'h2009ffff;
assign rom[5'h0C] = 32'h312affff;
assign rom[5'h0D] = 32'h01493025;
assign rom[5'h0E] = 32'h01494026;
assign rom[5'h0F] = 32'h01463824;
assign rom[5'h10] = 32'h10a00001;
assign rom[5'h11] = 32'h08000008;
assign rom[5'h12] = 32'h2005ffff;
assign rom[5'h13] = 32'h000543c0;
assign rom[5'h14] = 32'h00084400;
assign rom[5'h15] = 32'h00084403;
assign rom[5'h16] = 32'h000843c2;
assign rom[5'h17] = 32'h08000017;
assign rom[5'h18] = 32'h00004020;
assign rom[5'h19] = 32'h8c890000;
assign rom[5'h1A] = 32'h20840004;
assign rom[5'h1B] = 32'h01094020;
assign rom[5'h1C] = 32'h20a5ffff;
assign rom[5'h1D] = 32'h14a0fffb;
assign rom[5'h1E] = 32'h00081000;
assign rom[5'h1F] = 32'h03e00008;
assign inst = rom[a[6:2]];
//end
endmodule
问题
为什么代码最后一行assign inst = rom[a[6:2]]; 是【6:2】,写0:4报错